Renaming destination file without using Rename in NSIS script
Asked Answered
A

2

8

If I have file being copied using the following

SetOutPath "$FOO_DIR"
File "..\..\Bar.Dat"

...

SetOutPath "$OTHER_FOO_DIR"
File "..\..\Bar.Dat"

Note that the file Bar.Dat is supposed to be copied to other locations later on to during the installation. How do I rename it for this specific copy operation? If I do a Rename on it the later operations will not find it. I have been looking for an option to pass a destination file name to the File operation, but can't find one.

Austral answered 12/7, 2012 at 6:17 Comment(0)
A
9

Of course I managed to find the answer straight after posting this question. *smack*

File does in fact take a flag of the destination name.

 File "..\..\Bar.Dat" /oname="DestinationNameOfFile.Dat"
Austral answered 12/7, 2012 at 6:19 Comment(1)
quote the entire parameter, including /oname, i.e. File "/oname=DestinationNameOfFile.Dat" "..\..\Bar.Dat"Qualm
C
12

Actually tried the above but the nsis compiler complains. a little bit of rearranging would make it work:

File /oname="DestinationNameOfFile.Dat" "..\..\Bar.Dat"

*the source filename is the 2nd argument for /oname

Cabriole answered 26/2, 2013 at 2:36 Comment(4)
Which version of NSIS did you use? The way I described worked in 2.46.Austral
oh yeah! forgot to check about that one. i'm using 2.46.Cabriole
I had an error when using this with quotes. Removing the quotes from the destination file name fixed it. Version 2.46Exacting
If the output name contains spaces, quote the entire parameter, including /oname, i.e.: File "/oname=nome with spaces.txt" "Original name.txt"Incommodious
A
9

Of course I managed to find the answer straight after posting this question. *smack*

File does in fact take a flag of the destination name.

 File "..\..\Bar.Dat" /oname="DestinationNameOfFile.Dat"
Austral answered 12/7, 2012 at 6:19 Comment(1)
quote the entire parameter, including /oname, i.e. File "/oname=DestinationNameOfFile.Dat" "..\..\Bar.Dat"Qualm

© 2022 - 2024 — McMap. All rights reserved.