NAME statement

Purpose

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

Syntax

NAME filespec1$ AS filespec2$

Remarks

The NAME statement comprises the following elements:

filespec1$

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).

filespec2$

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.

Restrictions

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.

Example

OldName$ = "MYFILE.EXE"

NewName$ = "YOURFILE.EXE"

NAME OldName$ AS NewName$