NAME statement


Rename a file or a directory (like the DOS REN command).


NAME filespec1$ AS filespec2$


The NAME statement comprises the following elements:


The current name of a file or directory.  The file must not be currently opened or lockedfilespec1$ may be either a Short File Name (SFN) or a Long File Name (LFN).


The desired name of the file or directory, and may use Long File Name (LFN) naming conventions.

Each filespec may contain drive and path specifications as well as a file or directory name.

If filespec1 does not exist, run-time Error 53 ("File not found") occurs.  If filespec2 already exists, run-time Error 58 occurs ("File already exists").  If filespec1 has been opened or locked by your application and not closed, an Error 51 can occur ("Internal system error").  You should never rename a file that has been opened by your code and not (yet) closed.


It is possible to move a file from one directory, drive, or partition, to another. It is not possible to move directories between drives or partitions. Wildcard characters are not permitted in the file names.


OldName$ = "MYFILE.EXE"


NAME OldName$ AS NewName$