rename( )
Topic group Related topics Example
Renames a file on disk.
Syntax
<oRef>.rename(<filename expC>, <new name expC>)
<oRef>
A reference to a File object.
<filename expC>
Identifies the file to rename (also known as the source file). <filename expC> may be a file name skeleton with wildcard characters. In that case, dBASE Plus displays a dialog box in which you select the file to rename.
If you specify a file without including its path, dBASE Plus looks for the file in the current directory, then in the search path(s) you specified with SET PATH, if any. If you specify a file without including its extension, dBASE Plus assumes no extension. If the named file cannot be found, an exception occurs.
<new name expC>
Identifies the new name for the source file (also known as the target file). <new name expC> may be a file name skeleton with wildcard characters. In that case, dBASE Plus displays a dialog box in which you specify the name of the target file and its directory.
Property of
File
Description
rename( ) lets you change the name of a file at the operating system level.
If SET SAFETY is ON and a file exists with the same name as the target file, dBASE Plus displays a dialog box asking if you want to overwrite the existing file. If SET SAFETY is OFF and a file exists with the same name as the target file, an exception occurs, and the target file is not overwritten.
If you specify a different drive or directory for the target file, dBASE Plus moves the source file to that location. When a path is not specified, the target file is moved to the current directory.
rename( ) does not automatically rename the auxiliary files associated with table files, such as indexes and memo files. For example, it does not rename the MDX or DBT files associated with a DBF file. When renaming tables, use the Database object’s renameTable( ) method.