Archive: Rename vs CopyFiles?


Rename vs CopyFiles?
What I don't get is this:

4.9.1.6 Rename

[/REBOOTOK] source_file dest_file

Rename source_file to dest_file. Functions just like the Win32 API MoveFile, which means you can move a file from anywhere on the system to anywhere else, and you can move a directory to somewhere else on the same drive. If /REBOOTOK is specified, and the file cannot be overwritten, then the file is moved when the system reboots -- if the file will be moved on a reboot, the reboot flag will be set. The error flag is set if the file cannot be renamed (and /REBOOTOK is not used) or if the source file does not exist.

How does it move a DIR somewhere? I'v tryed these:
Rename "$INSTDIR\cstike\sound\weapons\*.*" "$INSTDIR\cstrike\xls-backup\*.*"

Rename "$INSTDIR\cstike\sound\weapons\" "$INSTDIR\cstrike\xls-backup\"

Rename "$INSTDIR\cstike\sound\weapons" "$INSTDIR\cstrike\xls-backup"

And:
CopyFiles "$INSTDIR\cstike\sound\weapons\*.*" "$INSTDIR\cstrike\xls-backup\*.*"

CopyFiles "$INSTDIR\cstike\sound\weapons\" "$INSTDIR\cstrike\xls-backup\"

CopyFiles "$INSTDIR\cstike\sound\weapons" "$INSTDIR\cstrike\xls-backup"

But nothing ever happens. When I use CopyFiles it writtes to the Details window "Copy failed", with the Rename, nothing at all.


You need to create the parent directory before renaming/copying files.

E.g. CopyFiles $INSTDIR\blah $INSTDIR\blah\ja
This will only work if the directory "ja" exists:
CreateDirectory $INSTDIR\blah\ja

I think this goes for Rename too.

-Stu


This is all of it:

CreateDirectory "$INSTDIR\cstrike\xls_backup"
CopyFiles $INSTDIR\cstike\sound\weapons $INSTDIR\cstrike\xls_backup
RMDir /r "$INSTDIR\cstrike\sound\weapons"
CreateDirectory "$INSTDIR\cstrike\sound\weapons"
SetOutPath "$INSTDIR\cstrike\sound\weapons"
File /r "cstrike\sound\weapons\*.*"

This is the install details:

Remove folder: C:\Documents and Settings\Administrator\Start Menu\Programs\x-systems\xls
Create folder: C:\Documents and Settings\Administrator\Desktop\cstrike\xls_backup
Copy to C:\Documents and Settings\Administrator\Desktop\cstrike\xls_backup
Copy failed
Remove folder: C:\Documents and Settings\Administrator\Desktop\cstrike\sound\weapons
Create folder: C:\Documents and Settings\Administrator\Desktop\cstrike\sound\weapons
Output folder: C:\Documents and Settings\Administrator\Desktop\cstrike\sound\weapons
Created uninstaller: C:\Documents and Settings\Administrator\Desktop\cstrike\xls_backup\unxls.exe
Create folder: C:\Documents and Settings\Administrator\Start Menu\Programs\x-systems
Create folder: C:\Documents and Settings\Administrator\Start Menu\Programs\x-systems\xls
Create shortcut: C:\Documents and Settings\Administrator\Start Menu\Programs\x-systems\xls\Uninstall.lnk
Completed