Copy Files in NSIS
Asked Answered
C

2

6

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 first 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.

Citrate answered 14/9, 2010 at 16:49 Comment(3)
You question does not really make any sense, to confuse things further, the NSIS File instruction extracts files from yourinstaller.exe but NSIS also has a command called CopyFiles that copies files on the end users systemDerickderide
Mr. Anders, I added what i think is a better explanation. What do you think?Citrate
I do not understand your question either, unless you mean that you want nsis to rename copies of existing files for you, instead of overwriting. ex) if MyDocument.txt exists to rename it to MyDocument(1).txt and then write itImago
T
4

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.

Trucker answered 17/11, 2010 at 22:28 Comment(0)
O
1

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?

Otology answered 11/1, 2011 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.