Rename File

Verb: fileRename

Renames a file with the name entered in the New Name input parameter.

Syntax

fileRename --file(String) --newname(String) [--fileSystem(FileSystem)] (String)=value

Inputs

Script Designer Required AcceptedTypes Description
--file File Path Required Text Full path to the file that should be renamed.
--newname New Name Required Text New filename and its extension.
If you enter the filename with the extension, it will also be changed.
--fileSystem File System Optional File System File system connection variable.
1. To obtain the connection variable with an available file system, this connection must be established using one of the following commands: IBM RPA Control Center.
2. If nothing is specified in this parameter, the operating system's local file system is used by default.

Outputs

Script Designer AcceptedTypes Description
value Path Text Returns the path to the renamed file.

Example

Example 1: In this first situation, the Rename File command is used to rename the file with the new name given in the New Name input parameter, without changing its extension.

defVar --name modifiedFilePath --type String
// Download the following file to execute the command.
fileRename --file "oldFileName.txt" --newname "newFileName" modifiedFilePath=value
logMessage --message "${modifiedFilePath}" --type "Info"
// After the script is executed it returns the file path with the modified file name.

Example 2: In this second situation, the Rename File command is used to rename the file with the new name given in the New Name input parameter, while also changing its extension.

defVar --name modifiedFilePath --type String
// Download the following file to execute the command.
fileRename --file "oldFileName.txt" --newname "newFileName.html" modifiedFilePath=value
logMessage --message "${modifiedFilePath}" --type "Info"
// After the script is executed, it returns the file path with the modified file name.

Download File


For the correct operation of the script above, it is necessary to download the file and insert its path in the Path parameter of the Rename File command.

See Also

  • Check If Directory Exists
  • Convert Base64 to File
  • Convert File to Base64
  • Copy File
  • Count Files
  • Create Directory
  • Delete Directory
  • Delete File
  • Delete from Directory
  • Download from File System
  • Get Directories
  • Get Files
  • If File Exists
  • Move File
  • Read All Bytes
  • Read All Text
  • Send to File System
  • Write to File