Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- copyall: Version 0.1
- -- Copys all files from source to destination
- -- Written by HarvDad, March 2014
- args = {...}
- nArgs = #args
- usage = "Usage: copyall <src directory><dst directory>"
- if (nArgs == 0 or args[1]== "help") then
- print("Copys all files from source to destination")
- print(usage)
- return
- end
- if nArgs ~= 2 then
- print(usage)
- return
- end
- src = args[1]
- dst = args[2]
- list = fs.list(src)
- for i=1,#list do
- if not fs.isDir(list[i]) then
- filename = list[i]
- -- print(filename)
- firstchar = string.sub(filename, 1, 1)
- -- print("firstchar = ", firstchar)
- if firstchar ~= "." then
- srcpath = src .. "/" .. filename
- dstpath = dst .. "/" .. filename
- print("Copying ", srcpath, " to ", dstpath)
- if fs.exists(dstpath) then
- fs.delete(dstpath)
- end
- fs.copy(srcpath, dstpath)
- else
- print("Ignoring: ", filename)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement