RenameFile
See Also: File I/O Commands, CopyFile, Direct_Input, EraseFile
Purpose
To change the name of a disk file.
Syntax
RenameFile {old-filename} to {new-filename}
where:
- {old-filename} may contain a folder path.
- {new-filename} may not contain a folder path.
What It Does
RenameFile changes the name of a disk file. After renaming, the new file will appear in the same folder that the old file was in.
Example
This sample renames the file "vendor.txt" in the "C:\MyProject\Text Files" folder to "seller.txt".
RenameFile "C:\MyProject\Text Files\vendor.txt" to "seller.txt"
Notes
- You may use "wild-card" (ambiguous) filenames with
RenameFileprovided your operating system supports such usage in its rename function. - If
RenameFileis executed on a non-existent {old-filename}, no error will be triggered, and no file will be affected in any way. - If {new-filename} already exists, no error will be triggered and no file will be affected in any way. Use File_Exist to check whether the file already exists.
- If {new-filename} contains a path, no error will be triggered and no file will be affected in any way.
- When a DFPATH is in effect: If {old-filename} contains no folder name, the first path in DFPATH will be used.