--[[ Name: masscopy Description: Allows you to copy all of the files in one directory to another Author: Kreezxil Date: 9/14/2013 ]]-- args = { ... } if #args == 0 then print("Usage: ") print(" masscopy [-f]") print("") print(" where and are both directories.") print(" -f can specified and will force overwriting.") end if args[1] ~= nil then source = shell.resolve(args[1]) if not fs.isDir(source) then print("Error! Invalid source directory specified. Try again.") return end end if args[2] ~= nil then dest = shell.resolve(args[2]) if not fs.isDir(dest) then print("Creating destination directory " .. dest) fs.makeDir(dest) end end list = fs.list(source) for _,file in ipairs(list) do exists=false if fs.exists("/" .. dest .. "/" .. file) then exists=true if args[3] ~= "-f" then print("File " .. file .. " exists at destination! Overwrite? (y/n)") ans = read() else ans = "y" -- because -f was used end if string.find("Yy",ans) ~= nil then exists=false fs.delete("/" .. dest .. "/" .. file) end end if not exists then fs.copy("/" .. source .. "/" .. file,"/" .. dest .. "/" .. file) print("Copying file " .. file .. " to " .. "/" .. dest .. "/" .. file) else print("Not Copying file " .. file .. " to " .. dest .. " per your instructions.") end end print("Done Copying!")