RenameFile

InstallShield 2019 » InstallScript Language Reference

The RenameFile function changes the name of a file or directory and/or moves a file or directory (and its subdirectories and files) from one parent directory to another.

Note • Note the following:

If szSource and szTarget reference the same directory or—when using unqualified names, if SRCDIR and TARGETDIR reference the same directory for an InstallScript installation (or if SRCDIR and INSTALLDIR reference the same directory for a Basic MSI or InstallScript MSI installation)—the file or directory that is specified by szSource is renamed, unless a file or directory with the name that is specified by szTarget already exists in that directory.
If szSource and szTarget reference different directories or—when using unqualified names, if SRCDIR and TARGETDIR reference different directories for an InstallScript installation (or if SRCDIR and INSTALLDIR reference different directory for a Basic MSI or InstallScript MSI installation)—the file or directory that is specified by szSource is moved to the new directory and given the name that is specified by szTarget, unless a file or directory with that name already exists in that directory.

Syntax

RenameFile ( szSource, szTarget );

Parameters

RenameFile Parameters

Parameter

Description

szSource

Specifies the name of the file or directory to be renamed or moved. If szFileOld specifies a fully qualified file name or directory (it includes a path), RenameFile renames or moves the file or directory in the specified directory. If szSource contains an unqualified file name or directory name (without path information), RenameFile renames or moves the file or directory in the directory specified by the system variable SRCDIR.

Note • Wildcard characters are not permitted. Only one file or one directory (including its subdirectories and folders) can be renamed or moved with each call to RenameFile.

szTarget

Specifies a new name and/or location for the file or directory. If szFileNew specifies a fully qualified file name or directory (it includes a path), RenameFile renames the file or moves it to the specified directory. If szFileNew contains an unqualified file name or directory name (without path information), RenameFile either renames the file or directory, or moves the file or directory to the directory specified by the system variable TARGETDIR (for an InstallScript installation) or the system variable INSTALLDIR (for a Basic MSI or InstallScript MSI installation).

Return Values

RenameFile Return Values

Return Value

Description

0

Indicates that the function successfully changed the name of the file or directory or moved the file or directory.

< 0

Indicates that the function was unable to change the name of the file or folder or move the file or folder.

See Also