Archive: How to not copy specific folders?


How to not copy specific folders?
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)


You need RecFind from: http://nsis.sourceforge.net/wiki/Req...t%2C_FindClose

!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


-Stu

You can try also:

Name "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
Script uses header

Originally posted by Afrow UK
You need RecFind from: http://nsis.sourceforge.net/wiki/Req...t%2C_FindClose

<snip>


-Stu
I keep getting the following:

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



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


Function CopyUserFiles
Push $R1
Push $R2
${RecFindOpen} "D:\Test" $R1 $R2
${RecFindFirst}
StrCmp $R1 "Default" Found
${RecFindNext}
Found:
${RecFindClose}
Pop $R2
Pop $R1
FunctionEnd


Uploaded new version with some error checking.

-Stu

Got it working perfectly.:D
Thanks for the help!