RENAME
The RENAME command can be used to rename a specified local file to a new name.
The file specified in for the TO value must be in the same directory as the file specified in the FROM value.
Required
RENAME ------- FROM --------- file path ------------------------->
>-- TO ----------- file path ------------------------->
Optional
>-- REPLACE ------ *NO -------------------------------|
*YES
Keywords
FROM |
This keyword specifies the name and path of the file whose name is to be changed. It is recommended to use the forward slash as the path separator and to avoid the use of the DOS drive designator. The format of the path should be as follows: For Windows you can specify:
For the IBM i you can specify:
This keyword is mandatory. |
TO |
This keyword specifies the name and the path to which the file is to be changed to. The path must be the same as that specified in the FROM keyword. It is recommended to use the forward slash as the path separator and to avoid the use of the DOS drive designator. The format of the path should be as follows: For Windows you can specify: Absolute path.
Relative path.
For the IBM i you can specify: Absolute path.
Relative path.
This keyword is mandatory. |
REPLACE |
This keyword is used to specify whether you want to overwrite any existing file of the same name as specified in the TO keyword. There are two possible values: *YES - specifying this value will overwrite any existing file of the same name in the specified directory.. *NO - if this value is set then an exception will occur if a file of the same name already exists in the directory. If you capture this exception you can report it back to the user. The default value is *NO. This keyword is optional. |
Comments / Warnings
If you wish to place the file into another directory, you might want to consider using the ARCHIVE keyword on the READ command. This keyword will move the file that you are currently READing and place it into a new specified directory with whatever name you give it.
Examples
RDML
* Define JSM fields
DEFINE FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)
DEFINE FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)
DEFINE FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)
* Rename
CHANGE FIELD(#JSMCMD) TO('''RENAME FROM(/orders/test.xml) TO(/orders/rename.xml) REPLACE(*YES)''')
USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)
RDMLX
* Define the fields used by the JSM Commands
Define Field(#JSMSTS) Type(*CHAR) Length(020)
Define Field(#JSMMSG) Type(*CHAR) Length(256)
Define Field(#JSMCMD) Type(*CHAR) Length(256)
Define Field(#JSMHND) Type(*CHAR) Length(4)
* Rename
Change Field(#JSMCMD) To('''RENAME FROM(/orders/test.xml) TO(/orders/rename.xml) REPLACE(*YES)''')
Use Builtin(JSMX_COMMAND) With_Args(#JSMCMD) To_Get(#JSMSTS #JSMMSG #JSMHND)