This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
WolfDood's profile picture

[[ Wolf-Cleanup tool ]] Get rid of all user-made files

Started by WolfDood, 25 November 2016 - 05:57 AM
WolfDood #1
Posted 25 November 2016 - 06:57 AM
Okay I'll keep this short. Let's say you have to many programs, or you want to troll your friend (Not responsible) but you can't be stuffed deleting them one by one well.. I have a program for that. It is called… Wolf-Cleanup It is a cleanup program that will get rid of all user-made programs.

Here is the pastebin link: http://pastebin.com/s41wJP5i

And here is to do it in-game: pastebin get s41wJP5i cleanup

Hopefully you will enjoy this :)/>

SpoilerScreenshots:[attachment=2696:Capture1.PNG][attachment=2697:Capture3.PNG][attachment=2698:Capture4.PNG]
TheRockettek #2
Posted 25 November 2016 - 07:11 AM
you could just do "rm *" …
EveryOS #3
Posted 25 November 2016 - 07:40 PM
Hey, I noticed it deletes ALL files.
What if you added the ability to run it in multiple ways:

#cleanup
Cleaning ALL files
[is this not what you want? cleanup -h]
Are you sure?
[y/n]—
Deleting all files

#cleanup folder1 folder2 file1 file2
Cleaning...
rm'ing folder folder2 file1 file2
--...

#cleanup -ex folder 2
Removing all but folder 2

#cleanup -v
Removed file1, a file
Unable to remove rom
Unable to remove disk
removed folder1, a folder

#cleanup -h
Cleanups files for yoi

Usage:
Cleanup -- Remove all files
Cleanup -h --This screen

Optional args
 choose files to delete
[-ex] Switch files params with all other files
[-v] Print whats happening
HaddockDev #4
Posted 26 November 2016 - 03:11 PM
I improved your program. Dunno why, I just did.
code

term.setBackgroundColor(colors.blue)
term.clear()
term.setCursorPos(1, 1)
print("Wolf-Cleanup by WolfDood")
print("Are you sure you want to delete all files (Including this one)? y/n")
write(">> ")
yorn = read()
if yorn:lower() == "y" then
for _, f in ipairs(fs.list("")) do
   if not fs.isReadOnly(f) then
  fs.delete(f)
   end
end
print("All done! Goodbye!")
os.sleep(2)
os.reboot()
elseif not yorn:lower() == "y" then
print("Clean up cancelled")
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1, 1)
end