Name

Syntax

Name OldName$ As NewName$

Remarks

Renames a file. If you do not include paths with the OldName$ and NewName$ arguments, Name assumes the current folder — the one selected in the Open dialog box (File menu). In Windows, you can move a file to a different folder by including a different path for NewName$; however, you cannot use Name to move folders or to move a file to a different drive. On the Macintosh, the path for OldName$ must match the path for NewName$ or an error occurs.

Argument

Explanation

OldName$

The previous name of the file. If the filename specified by OldName$ does not exist or is open, an error occurs.

NewName$

The new name of the file. If the filename specified by NewName$ already exists, an error occurs.


The OldName$ and NewName$ arguments do not accept wildcard characters — the asterisk (*) and question mark (?).

Examples

This example uses ChDir to set the current folder, and then renames the file COGS.DOC as COGS88.DOC in that folder. Without the ChDir instruction preceding it, the Name instruction would need to specify the complete path for each filename. On the Macintosh, substitute a folder name such as HD:DOCS:MEMOS:JULY in the ChDir instruction.


ChDir "C:\MYDOCS\MEMOS\JULY"
Name "COGS.DOC" As "COGS88.DOC"

The following Windows example moves the file COGS.DOC to a different folder and leaves the filename unchanged:


Name "C:\TMP\COGS.DOC" As "C:\DOCS\COGS.DOC"

See Also

ChDir, CopyFile, FileSaveAs, Kill, MkDir, RmDir