Skip to content
⌘ NSIS Forum Archive

Copy files if newer

7 posts

mezcalin#

Copy files if newer

Hi

I have to copy files if they are newer.
Some ideas, how to do that? Need help.

Thanks
fyaa#
Well as I don't know how to read these addtional file informations.. maybe write the last_modified date into the registry and read it out?
This might work if it's for an updater where you can be sure to set this entry at first.
Afrow UK#
You need to provide more information. Are you talking about extracting files from the installer (File)? Or are you talking about CopyFiles?

Stu
mezcalin#
I'm talking about CopyFiles, but CopyFiles won't work, because there is no option like /ifnewer or something like that.
Afrow UK#
You'll need to do the checks yourself. You can recurse through files and folders using Locate (see docs). Use GetFileTime to compare files.

Stu
mezcalin#
Hmm...
I think it's not the smartest way to do, but I'll use the windows-tool robocopy instead of check all files by myself.
jpderuiter#
The basic code is available:

If you want to copy instead of move a file, just change the 'rename' calls to 'CopyFiles' and remove the 'delete "${sourceFile}"' calls.