Skip to content
⌘ NSIS Forum Archive

[NSIS] How to rename a file?

11 posts

tribaleur#

[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. 👍
tribaleur#
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!! 👍
jpderuiter#
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"
mbg#
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#
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#
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.