Advertisement
denesik

cpfiles

Nov 14th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. local function printUsage()
  2.   print( "Usages:" )
  3.   print( "cpfiles <input dir> <output dir>" )
  4. end
  5.  
  6. local tArgs = { ... }
  7. if #tArgs < 2 then
  8.   printUsage()
  9.   return
  10. end
  11.  
  12. indir=tArgs[1]
  13. if(not(fs.isDir(indir)))then
  14.   print( "Not a directory" )
  15.   return
  16. end
  17. outdir=tArgs[2]
  18. if(not(fs.isDir(outdir)))then
  19.   print( "Not a directory" )
  20.   return
  21. end
  22. FileList=fs.list(indir)
  23. CountFiles=#FileList
  24. for i=1,CountFiles do
  25.   if(not(fs.exists(outdir.."/"..FileList[i])))then
  26.     if(not(fs.isDir(indir.."/"..FileList[i])))then
  27.       fs.copy(indir.."/"..FileList[i],outdir.."/"..FileList[i])
  28.       if not(fs.exists(outdir.."/"..FileList[i])) then
  29.         print(FileList[i].." was not copied")
  30.       end
  31.     end
  32.   end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement