Skip to content
⌘ NSIS Forum Archive

Issue with moving folders

6 posts

Mircea M#

Issue with moving folders

Hi,

I am having some weird trouble with moving (renaming) folders. I have the following 2 definitions:
!define IDI_TEMP_BACKUP_DIR "$TEMP\$currentBackup"
!define IDI_BACKUP_DIR "$INSTDIR\backups\$currentBackup"
($currentBackup is a string that is generated in .onInit based on date and time - this works)

During my installation I create some backups and place them in TEMP since I actually create a backup of the existing backup folder. When everything is done, I move the backup from TEMP back to my $INSTDIR like this:
CreateDirectory "$INSTDIR\backups"
Rename "${IDI_TEMP_BACKUP_DIR}" "${IDI_BACKUP_DIR}"
The trouble is, this sets the error flag and my backup remains in TEMP. Any idea what I'm doing wrong?

Thanks,
Mircea
Anders#
The docs say the destination cannot exist. Also, you cannot use rename to move a folder to a different partition and you don't control %temp% so you might have to rethink your design... (Call some other API directly with the system plug-in or use $instdir\temp)
Mircea M#
Thanks Anders! The problem was the order in which I defined some of the constants that I use, I believe. Changed the order and it works now.
JasonFriday13#
Originally Posted by Anders View Post
Also, you cannot use Rename to move a folder to a different partition
Did you not see this reply? You will have to use CopyFiles and Delete, or something similar.
Mircea M#
I did. I was not moving to a different partition. %TEMP% is on C:\ and $INSTDIR is also on C:\. That was not the issue. The issue was that I was using a different variable to define my IDI_BACKUP_DIR dir (not $INSTDIR) which in this case had the same value but was defined only after I defined IDI_BACKUP_DIR. I suspect that because of this the path was "unknown". As soon as I changed this variable to $INSTDIR all worked.
JasonFriday13#
Interesting, I thought that rename doesn't move files around and it only changes the filename part (not the path).