Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local files = 0
- -- Get all the files in the directory
- local sDir = shell.dir()
- if tArgs[1] == "0" then
- local copy = false
- elseif tArgs[1] == "1" then
- local copy = true
- else
- error("Invalid argument. '1' to copy, or '0' to not.")
- end
- -- Sort into dirs/files.
- local tAll = fs.list( sDir )
- local tFiles = {}
- local tDirs = {}
- term.clear()
- term.setCursorPos(1,1)
- print("What would you like to save this transfer as?")
- local input = read()
- if fs.exists("disk/transfer"..input) then
- error("Transfer already exists.")
- else
- id = input
- end
- for n, sItem in pairs( tAll ) do
- if string.sub( sItem, 1, 1 ) ~= "." then
- local sPath = fs.combine( sDir, sItem )
- if fs.isReadOnly( sPath ) ~= true then
- if fs.isDir("disk") then
- fs.makeDir("disk/transfer"..id)
- if copy == false then
- fs.move( sPath, "disk/transfer"..id.."/"..sPath) -- Move the files to disk.
- files = files + 1
- else
- fs.copy( sPath, "disk/transfer"..id.."/"..sPath)
- files = files + 1
- end
- else
- error("No disk inserted.") -- Error: No disk.
- end
- end
- end
- end
- files = tostring(files)
- print("Transfered "..files.." files to disk/transfer"..id.."!")
Advertisement
Add Comment
Please, Sign In to add comment