Renaming a file (#FILE RENAME)
The command #FILE RENAME renames an existing file. All parameters must be specified. Omitting a parameter leads to a corresponding error message.
Syntax: |
#FILE RENAME [ PATHOLD="<filename>" PATHNEW="<filename>" OVRMODE=.. ] |
PATHOLD= | File to be renamed, possibly with directory specification. If this directory path or the file does not exist, the NC program is aborted with an error message. |
PATHNEW= | New (destination) file, possibly with directory specification. If a different directory path is specified here than at PATHOLD, the file is moved to the directory with the new name, provided the directory exists. If this directory is not found, a corresponding error message is output. |
OVRMODE=.. | Boolean value indicating whether a file specified by PATHNEW should be overwritten provided it already exists. 0: File may not be overwritten. output of an error message 1: Existing file may be overwritten. |
The equals sign (=) is optional.
Notice
The user must have write access to the directories PATHNEW and PATHOLD. Otherwise, renaming causes an error.
Attention
WRITE PROTECTION:
An error is generated if the file which is to be renamed is write-protected, it is an existing (destination) file and is protected.
Attention
RELATIVE DIRECTORIES:
If only the filename is specified at PATHOLD, a search is made for the file in the folders of the start-up/channel parameter list.
The search is for the sequence main program - subroutine - work directory.
If PATHNEW is specified as relative, the PATHOLD directory is used.
Programing Example
Renaming a file
%FileRename
N10 #FILE NAME[MSG="C:\Test.txt"] ;Create file
...
N40 #MSG SAVE["Write me into file"] ;Writes text to file
N60 #FILE RENAME[PATHOLD="C:\Test.txt" PATHNEW = "C:\NewName.txt" OVRMODE=1]
N70 M30