I need to copy a user's files from a previous install directory to the new install directory, but I do not want to copy any of the standard files that I install, only the ones that the user has created.
I can copy over all of the contents of a directory,
!macro CopyTemplates
CopyFiles /SILENT "$R0\a""$INSTDIR"
!macroend
(Where $R0 is the old install path)
Any ideas on how to not copy specific folders?
(i.e. I want to copy $R0\a and all of it's subfolders except for $R0\a\f and $R0\a\g)
How to not copy specific folders?
9 posts
You need RecFind from: http://nsis.sourceforge.net/wiki/Req...t%2C_FindClose
-Stu!include RecFind.nsh
Function CopyUserFiles
Exch $R0
Push $R1
Push $R2
${RecFindOpen} $R0 $R1 $R2
${RecFindFirst}
IfFileExists "$INSTDIR$R1\$R2" +2
CopyFiles "$R0$R1\$R2" "$INSTDIR$R1\$R2"
${RecFindNext}
${RecFindClose}
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
You can try also:
Script uses headerName "Output"
OutFile "Output.exe"
!include "FileFunc.nsh"
!insertmacro Locate
Section
StrCpy $R0 'C:\a' #source
StrCpy $R1 '$INSTDIR' #destination
${Locate} "$R0" "/L=D /G=0" "LocateCallback"
IfErrors 0 +2
MessageBox MB_OK "Error"
SectionEnd
Function LocateCallback
StrCmp $R7 'f' end
StrCmp $R7 'g' end
CreateDirectory "$R1\$R7"
CopyFiles /SILENT "$R9\*.*" "$R1\$R7"
end:
Push $0
FunctionEnd
Originally posted by Afrow UKI keep getting the following:
You need RecFind from: http://nsis.sourceforge.net/wiki/Req...t%2C_FindClose
-Stu<snip>
Error: could not resolve label "checkFile52.2D:\Test" in function "CopyUserFiles"
Error - aborting creation process
I am trying:
Function CopyUserFiles
Push $R1
Push $R2
${RecFindOpen} "D:\Test" $R1 $R2
StrCmp $R1 "Default" Found
${RecFindNext}
Found:
${RecFindClose}
Pop $R2
Pop $R1
FunctionEnd
Hmm, I see what the problem is.
Goto line 64 in Include\RecFind.nsh and change:
!define Local "${__LINE__}${Dir}"
To:
!define Local "${__LINE__}"
It's because D:\Test has a ":" in it which is used at the end of labels.
Edit: Uploaded fixed version: http://myweb.tiscali.co.uk/imker/downloads/RecFind.nsh
-Stu
Goto line 64 in Include\RecFind.nsh and change:
!define Local "${__LINE__}${Dir}"
To:
!define Local "${__LINE__}"
It's because D:\Test has a ":" in it which is used at the end of labels.
Edit: Uploaded fixed version: http://myweb.tiscali.co.uk/imker/downloads/RecFind.nsh
-Stu
Error: could not resolve label "checkFile54.2" in function "CopyUserFiles"
Error - aborting creation process
Ok, you're using it wrongly that's why it's not working.
You're missing ${RecFindFirst}
Check the readme again.
I'll add some code to prevent people making this mistake.
-Stu
You're missing ${RecFindFirst}
Check the readme again.
I'll add some code to prevent people making this mistake.
-Stu
Uploaded new version with some error checking.Function CopyUserFiles
Push $R1
Push $R2
${RecFindOpen} "D:\Test" $R1 $R2
${RecFindFirst}
StrCmp $R1 "Default" Found
${RecFindNext}
Found:
${RecFindClose}
Pop $R2
Pop $R1
FunctionEnd
-Stu
Got it working perfectly.😁
Thanks for the help!
Thanks for the help!