Skip to content
⌘ NSIS Forum Archive

Having trouble with Rename

3 posts

paraclete#

Having trouble with Rename

I'm trying to rename a file on the target system. According to makensis.html, the following ought to work, but I'm getting the error message, and the target file isn't renamed.

I assume I'm doing something wrong here ... any suggestions?

Function RenameStatsFile
File InvStats.sav
Rename InvStats.sav InvStats.xml
IfErrors RenameError NoRenameError
RenameError:
MessageBox MB_OK|MB_ICONSTOP "Unable to rename stats file"
Abort "Cancelling installation"
NoRenameError:
return
FunctionEnd
0mar#
Hey there. 🙂

I believe you're missing the path info. for the file you're trying to rename... Instead of writing:

Rename InvStats.sav InvStats.xml

try:

Rename "$INSTDIR\InvStats.sav" "$INSTDIR\InvStats.xml"

Hope that helps. 👍

Omar
paraclete#
Thanks for the "rapid response" You guys are GOOD!

Prov 15:23 (NIV) A man finds joy in giving an apt reply-- and how good is a timely word!

I thought about it some more and realized the better solution is

File InstallData\PsgStats.xml

but now I'm better informed about Rename. Thx for the help. Nsis is one of the nice utilities to work with because of the outstanding support. :-)