- NSIS Discussion
- [NSIS] How to rename a file?
Archive: [NSIS] How to rename a file?
tribaleur
4th August 2009 11:01 UTC
[NSIS] How to rename a file?
Hello.
I want to rename a file during the script execution, but I dont know how.
For exemple :
# Fichiers du répertoire "IMPRESSION"
SetOutPath "$INSTDIR\Impression\"
File ".\Fichiers\Contact.doc"
# Rename "$INSTDIR\Impression\Contact.doc" to "$INSTDIR\Impression\ContactProsp.doc" for exemple
I search "SetFileName" or "Rename" or "SetBaseName" but I didn't find it. :(
Could you help me pleaze?
Thanks. :up:
Afrow UK
4th August 2009 11:10 UTC
You didn't look hard enough. Rename is in the manual.
Stu
tribaleur
4th August 2009 11:21 UTC
Sorry, I had find the "Rename" function but I understood that it's for Folder.
The good syntax is it?
Rename "$INSTDIR\Impression\Contact.doc" "$INSTDIR\Impression\ContactProsp.doc"
Thanks!! :up:
Afrow UK
4th August 2009 11:32 UTC
It works with files and folders.
Stu
tribaleur
4th August 2009 12:35 UTC
Thanks
jpderuiter
4th August 2009 17:23 UTC
In your example (installing a file and then rename it) you can also use the /oname from the File command
SetOutPath "$INSTDIR\Impression\"
File /oname=ContactProsp.doc ".\Fichiers\Contact.doc"
tribaleur
5th August 2009 13:09 UTC
Ok Thanks for the information.
I will try it.
:up:
mbg
18th September 2012 11:43 UTC
Hi, I am trying todo something similar, but keep getting an error everytime.
MY folder structure is:
Folder1\file.xxx
Folder1\file2.xxx
Setup\NSISscript.nsi
I am using Modern UI(MUI2.nsh), with two option, the first should use file.xxx the other should use file2.xxx, but output file should be file.xxx for both, what I did is:
First:
SetOutPath "$INSTDIR\Folder1"
File /r /x .svn \
/x "..\Folder1\file2.xxx" \
"..\Folder1\*"
How do I make the second work? , I tried various variations of:
SetOutPath "$INSTDIR\Folder1"
File "/oname=..\Folder1\file2.xxx" "file.xxx"
But I keep getting the same error showing FILE syntax, any ideas?
mbg
18th September 2012 19:15 UTC
no ideas, I failed to explain my problem or such a basic question from someone who clearly fail to understand the manual is beneath you guys :(
demiller9
18th September 2012 23:58 UTC
It looks to me like you have the names reversed when you tried to use the /oname switch. The syntax is
SetOutPath "some\Folder\On\Users\System"
File /oname=NewAlias.xxx "Path\On\Build\SystemTo\Find\The\OriginalName.xxx"
oname stands for Output Name.
mbg
19th September 2012 01:47 UTC
yes, thanks !