Renames a file, directory or folder.
Name oldpathname As newpathname |
The Name statement syntax has the following parts:
Part | Description |
oldpathname | Required. A string specifying the name and path to an existing file. It may include folder and drive names. |
newpathname | Required. A string specifying the new file name and path. It may include folder and drive names. A file with such name must not exist. |
Both arguments, oldpathname and newpathname, should point to the same drive. If path specified in newpathname exists and is different to the path in oldpathname, the Name statement will move the file into the new directory or folder and rename it (if needed). If the paths in newpathname and oldpathname are different but the filenames are the same, the Name statement will move the file to the new directory or folder without renaming it. With the Name statement you can move a file from one directory to another, but you can't move a directory or a folder.
An attempt to renamed an open file using Name generates an error. You should close the file prior to renaming it. You can't use wildcards such as (*) or (?) in arguments of the Name statement.
Dim OldName, NewName OldName = "OLDFILE" NewName = "NEWFILE" ' Specifies filenames. Name OldName As NewName ' Renames the file. ' In Microsoft Windows: OldName = "C:\MYDIR\OLDFILE" NewName = "C:\YOURDIR\NEWFILE" Name OldName As NewName ' Moves and renames file. ' On the Macintosh: OldName = "HD:MY FOLDER:OLDFILE" |
See Also |
Kill Statement |