Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I copy files from the installer to the hard drive in NSIS but only if they do not already exist or are newer then the existing ones?

Tags:

file-io

nsis

At the moment I am using:

SetOutPath "$INSTDIR\folder\subfolder"
File /r ..\Output\*.*

The problem is when re-installing all files will be overwritten.

Questions:

  1. How do I copy the files from the installer only if they do not already exist in the target directory?

    and

  2. How do I overwrite those files in the target directory that are older then the ones in the installer?

Edit:

I found this macro: http://nsis.sourceforge.net/MoveFileFolder

like image 766
cfischer Avatar asked Aug 02 '12 08:08

cfischer


1 Answers

I think the best solution is to use the SetOverwrite flag:

http://nsis.sourceforge.net/Docs/Chapter4.html#4.8.2.8

This flag can be changed on the fly within a section.

So to answer the question specifically:

SetOverwrite off       # Only copy if file does not exist
File /r ..\Output\*.*


SetOverwrite ifnewer   # Only overwrite if installers' file is newer
File /r ..\Output\*.*
like image 156
RyanE Avatar answered Sep 23 '22 03:09

RyanE