Navigation: Language Reference > 13 - Built-in Functions >====== RENAME (change file directory name) ====== | |
RENAME(file,new file)
RENAME | Renames a FILE. |
file | The label of a FILE to rename, or a string constant or variable containing a file specification. |
new file | A string constant or variable containing a file specification. If the file specification does not contain a drive and path, the current drive and directory are assumed. If only the path is specified, the filename and extension of the original file are used for the new file. Files cannot be renamed to a new drive. |
The RENAME statement changes the file specification to the specification for the new file in the directory. The file to rename must be closed, or the “File Already Open” error is posted. If the file specification of the new file is identical to the original file, the RENAME statement is ignored. If any error is posted, the file is not renamed.
Since some file drivers use multiple physical disk files for one logical FILE structure, the default filename and extension assumptions are dependent on the file driver.
Errors Posted:
02 | File Not Found |
03 | Path Not Found |
05 | Access Denied |
52 | File Already Open |
Example:
RENAME(Text,'text.bak') !Make it the backup
RENAME(Master,'\newdir') !Move it to another directory
RENAME('C:\AUTOEXEC.BAT','C:\AUTOEXEC.SAV') !Make it the backup
See Also: