Copy directories and overwrite only older files

Recommended Posts

Zest 0

Zest 0

I would like to use dircopy in a script to copy a folder including all files and subfolders to another location, thereby only overwriting older files (to keep copying times to a minimum).The dircopy function unfortunately does not provide this option. Then I searched the forum and stumbled upon a FileCompare function to compare file attributes. So I thought of doing the copying by first getting a file list from each (sub)directory and then comparing each file to determine if the file should be copied or not. However, this seems complicated and I was hoping there is an easier way. I prefer not having to use windows shell commands like xcopy.

(Note: The source and target folders are read from an .ini file.)

Could anyone please help me out how to get this done or suggest a good approach at this?

Share this post

Link to post

Share on other sites

BrewManNH 1,154

BrewManNH 1,154

What exactly is that script snippet supposed to be doing? It doesn't look like it's complete or usable in its present state.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Share this post

Link to post

Share on other sites

Zest 0

Zest 0

I already have the check to determine if the .ini setting is a file or dir working and also the generation of a file list in case of a direcetory using the _FileListToArrayRec.

Copying of files is also working and I also have a check so using system environment variables (e.g. %windir%) is also taken into account. Now all I have to do is add the check to copy only newer files, as in Rogue5099's example.