Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fileName = "startup"
- if(fs.exists(fileName) == true)then
- shell.run("rename startup startupDEL")
- sleep(2)
- shell.run("File_Deleter")
- end
- local driveLocation = ""
- term.clear()
- term.setCursorPos(1,1)
- version = "1.15.2"
- author = "Mr John Dowe"
- scriptName = "Computer File Deleter"
- modified = " April 29, 2023"
- function listFiles(driveLocation)
- term.setTextColor( colors.cyan )
- print("List of Files")
- print("-------------")
- local FileList = fs.list("") --Table with all the files and directories available
- for _, file in ipairs(FileList) do --Loop. Underscore because we don't use the key, ipairs so it's in order
- local RO = fs.isReadOnly(file)
- local DIR = fs.isDir(file)
- if(RO == true)then
- term.setTextColor(colors.red)
- print("READ ONLY: " .. file)
- elseif(DIR == true)then
- term.setTextColor(colors.orange)
- print("DIR: " .. file)
- elseif (RO == false)then
- term.setTextColor( colors.white )
- print("FILE: " .. file) --Print the file name
- elseif(foundFile == true)then
- term.setTextColor(colors.blue)
- print("FOUND: rom")
- else
- print("FILE NOT FOUND")
- end
- end --End the loop
- term.setTextColor( colors.cyan )
- print("-------------")
- print("End of Files")
- end
- function deleteFile(file)
- fs.delete(file)
- local fileName = fs.exists(file)
- return fileName
- end
- function deleteLocalFile(driveLocation)
- term.setTextColor(colors.yellow)
- print("Would you like to delete ALL files? YES/NO")
- local answer = read()
- local answer = tostring(answer)
- local answer = string.lower(answer)
- local FileList = fs.list(driveLocation)
- term.setTextColor(colors.white)
- for _, file in ipairs(FileList) do
- local foundFile = fs.exists(file)
- local RO = fs.isReadOnly(file)
- local DIR = fs.isDir(file)
- if (answer == 'yes' and RO == false and DIR == false)then
- shell.run("label clear")
- for _, file in ipairs(FileList) do --Loop. Underscore because we don't use the key, ipairs so it's in order
- local fileDeleted = fs.exists(file)
- if(file == "rom" or RO == true)then
- print("SKIPPING: " .. string.upper(file))
- else
- repeat
- term.setTextColor(colors.pink)
- print("DELETING FILE: " .. string.upper(file))
- fileDeleted = deleteFile(file)
- sleep(2)
- until fileDeleted == false
- end
- end
- term.setTextColor(colors.lime)
- print("FILES DELETED!")
- sleep(1)
- term.setTextColor(colors.green)
- print("Rebooting OS")
- sleep(5)
- os.reboot()
- elseif(answer == 'no' and RO == true)then
- term.setTextColor(colors.orange)
- print("READ ONLY: " .. file)
- elseif(answer == 'no' and foundFile == false)then
- term.setTextColor(colors.red)
- print("FILE NOT FOUND")
- term.setTextColor(colors.white)
- else
- term.setTextColor(colors.purple)
- local getLabel = shell.run("label get")
- if(tostring(getLabel) == true)then
- getLabel = shell.run("label get")
- shell.run("label set " .. getLabel )
- else
- shell.run("label set " .. "PC:" .. os.getComputerID())
- end
- term.setTextColor(colors.lime)
- print("FILES ARE SAFE!")
- sleep(1)
- term.setTextColor(colors.green)
- print("Rebooting OS")
- sleep(5)
- os.reboot()
- end
- end
- end
- function printAll()
- for _, match in pairs( fs.complete( "", driveLocation,true,true ) ) do print( match ) end
- end
- function header()
- print(scriptName)
- print("LUA Script made by: " .. author)
- term.setTextColor(colors.lime)
- print("Version: ".. version)
- term.setTextColor(colors.white)
- print("Last Modified on:"..modified)
- print("Please wait while I load myself into the system")
- print("")
- sleep(10)
- term.clear()
- term.setCursorPos(1,1)
- print("Scanning Files.... 5")
- print("")
- sleep(1)
- term.clearLine()
- term.setCursorPos(1, 1)
- print("Scanning Files.... 4")
- print("")
- sleep(1)
- term.clearLine()
- term.setCursorPos(1, 1)
- print("Scanning Files.... 3")
- print("")
- sleep(1)
- term.clearLine()
- term.setCursorPos(1, 1)
- print("Scanning Files.... 2")
- print("")
- sleep(1)
- term.clearLine()
- term.setCursorPos(1, 1)
- print("Scanning Files.... 1")
- print("")
- sleep(1)
- term.clear()
- term.setCursorPos(1, 1)
- listFiles(driveLocation)
- sleep(5)
- deleteLocalFile(driveLocation)
- end
- header()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement