0

Im trying to copy files from a folder using

FileCopy($Source & "*.*,$Dest",8)

Since the source folder has huge files and every hour new files gets added, i wanted to copy only the newer files (not present in the destination directory)

I don't want to use overwrite(9) option to avoid unwanted copying.

But if I don't use the overwrite filecopy stops updating new files (guess it stops the moment it finds an source file existing on destination directory)

Is there any other built-in function that just skips overwriting and still copies the new files???

Thanks in advance.

Siva
  • 294
  • 1
  • 9
  • 25
  • Why not writing it yourself? _FileListToArray [local] - then Loop through the files - if Not FileExists(...)[remote] Then FileCopy. That's it. If you are not able. Let me know and I post an example. – Xenobiologist Nov 21 '13 at 16:42
  • YEp..I can do that...but i thought this is a very basic thing which should be available as part of some of the standard functions .Thanks for your help though! – Siva Nov 21 '13 at 17:39

1 Answers1

3

I assume you want it for backup.
The one liner in autoit would be:

Runwait(@ComSpec & " /c " & "xcopy " & '"' & $source & '"' & ' "' & $destination & '"' & " /E /C /D /Y","",@SW_HIDE)
  • Will not overwrite unless the source file is newer(/D).
  • Will create directory structure, even the empty ones(/E).
  • Will copy hidden files (/H).
  • Will not stop on errors(/C).

For example:

$source = "D:\PROGRAMING BRE !!!"
$destination = "M:\PROGRAMING BRE !!!"
$timer = TimerInit()

Runwait(@ComSpec & " /c " & "xcopy " & '"' & $source & '"' & ' "' & $destination & '"' & " /E /C /D /Y /H /J","",@SW_HIDE)

MsgBox(0,"","Done in " & TimerDiff($timer)/1000 & " seconds!")

While this is not a pure Autoit, but an implementation of XCOPY it does the job very well.

Its lightning fast!

1GB 18.020 Files, 2.224 Folders 38sec!

To recheck all those files and add new ones 2sec!

Milos
  • 2,927
  • 1
  • 15
  • 27
  • Thanks Milos! I implemented pretty much the same as you mentioned but using robocopy http://stackoverflow.com/questions/4228807/copy-files-w-o-overwrite – Siva Nov 27 '13 at 19:30
  • Robocopy has more options, but what about the speed? – Milos Nov 27 '13 at 20:18