rename_file


The rename_file function changes the name of a file. Both the current ("old") file name and new file name are specified using their full path, for example, strings or values equal to "D:\\data\\2022-06-14\\data\\my_new_file.txt" and "D:\\data\\2022-06-14\\data\\my_renamed_file.txt. " Note that Windows directory components must be separated by the '\\' or '/' characters.

Syntax

bSuccess, sMsg = rename_file( sOldPathName, sNewPathName )

bullet.gif    sOldPathName is the current full path name of the file.

bullet.gif    sNewPathName is the full path name for the renamed file.

bullet.gif    bSuccess is true if the function is successful or false if not.

bullet.gif    sMsg is an optional message string that recieves information about the failure.

Remarks

If the current file name does not exist or the target file already exists, rename_file will fail and return false plus an error message. You can use is_file to test whether the file was renamed.

Related Topics

Directory Functions, is_file, make_file, remove_file


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.