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.
![]() | The user must have write access to the directories PATHNEW and PATHOLD. Otherwise, renaming causes an error. |
Notice | |
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. |
Notice | |
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. |
![]() | In addition, the default directory for the file operation is used in TwinCAT. This setting is made in the System Manager. |
Programming Example
Renaming a file