Copy Files in NSIS
I am using the following command to copy files.
After setting output path...
File "Documents\*"
This action works flawlessly. There are no issues coping the files in the Documents directory until...
if there is a copy of an existing file (with a different name) in the directory only the fi开发者_StackOverflow社区rst instance of the file gets copied regardless of name.
How do I make it so it will copy ALL files regardless if they are copies of other files?
Correction/better explanation (maybe)
I apologize for the confusion. Allow me to try to restate the problem. The files being extracted by using the FILE command is the issue here. The files consists of original files and copies of the same files (only with a different name).
example: MyDocument.txt and copyOfMyDocument.txt and so on..
When the File command is applied, in order to be extract the files to the current output path, only the first instance of the file is extracted (either the copy or the original... but not both). Again, I am sorry for the confusing but this is the first time I've had to work with NSIS. I need to extract ALL files.
The easiest way to do this will be to put it in a different directory which you've created. Then, if you need to worry about renaming (as the commentators have noted your question doesn't make much sense), you can attack it file by file.
# Extract the files to a directory which can't exist beforehand
CreateDirectory $PLUGINSDIR\extracting
SetOutPath $PLUGINSDIR\extracting
File Documents\*
# Now go through file by file
FindFirst $0 $1 $OUTDIR\*
${While} $1 != ""
${If} ${FileExists} $DOCUMENTS\$1
# This still isn't infallible, of course.
Rename $DOCUMENTS\$1 $DOCUMENTS\$1.local-backup
${EndIf}
Rename $OUTDIR\$1 $DOCUMENTS\$1
FindNext $0 $1
${Loop}
FindClose $0
SetOutPath $INSTDIR # Or somewhere else
RMDir $PLUGINSDIR\extracting
(Note that that's using LogicLib.)
This doesn't become a very neat way of doing it though and if you can avoid it, do.
i thought i understood what you were after, until i started reading the responses; i'll go with my initial interpretation: given a directory named "Documents", with a bunch of files in it (what they're called, and their contents should not matter), you want an installer that will copy the files into some output directory. I've created a test installer for this scenario here, and it works for me. What am I missing in what you're after?
精彩评论