Old 4th August 2009, 11:01   #1
tribaleur
Junior Member
 
Join Date: Aug 2009
Posts: 4
Question [NSIS] How to rename a file?

Hello.

I want to rename a file during the script execution, but I dont know how.

For exemple :

code:
# 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 is offline   Reply With Quote
Old 4th August 2009, 11:10   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You didn't look hard enough. Rename is in the manual.

Stu
Afrow UK is offline   Reply With Quote
Old 4th August 2009, 11:21   #3
tribaleur
Junior Member
 
Join Date: Aug 2009
Posts: 4
Sorry, I had find the "Rename" function but I understood that it's for Folder.

The good syntax is it?
code:
Rename "$INSTDIR\Impression\Contact.doc" "$INSTDIR\Impression\ContactProsp.doc"


Thanks!!
tribaleur is offline   Reply With Quote
Old 4th August 2009, 11:32   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
It works with files and folders.

Stu
Afrow UK is offline   Reply With Quote
Old 4th August 2009, 12:35   #5
tribaleur
Junior Member
 
Join Date: Aug 2009
Posts: 4
Thanks
tribaleur is offline   Reply With Quote
Old 4th August 2009, 17:23   #6
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
In your example (installing a file and then rename it) you can also use the /oname from the File command
code:
SetOutPath "$INSTDIR\Impression\"
File /oname=ContactProsp.doc ".\Fichiers\Contact.doc"

jpderuiter is offline   Reply With Quote
Old 5th August 2009, 13:09   #7
tribaleur
Junior Member
 
Join Date: Aug 2009
Posts: 4
Ok Thanks for the information.

I will try it.

tribaleur is offline   Reply With Quote
Old 18th September 2012, 11:43   #8
mbg
Junior Member
 
Join Date: Sep 2012
Posts: 5
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 is offline   Reply With Quote
Old 18th September 2012, 19:15   #9
mbg
Junior Member
 
Join Date: Sep 2012
Posts: 5
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
mbg is offline   Reply With Quote
Old 18th September 2012, 23:58   #10
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
It looks to me like you have the names reversed when you tried to use the /oname switch. The syntax is
code:
SetOutPath "some\Folder\On\Users\System"
File /oname=NewAlias.xxx "Path\On\Build\SystemTo\Find\The\OriginalName.xxx"

oname stands for Output Name.
demiller9 is offline   Reply With Quote
Old 19th September 2012, 01:47   #11
mbg
Junior Member
 
Join Date: Sep 2012
Posts: 5
yes, thanks !
mbg is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump