FTP - Rename file(s)

Declaration

<AMFTP ACTIVITY="rename" SOURCE="text" DEST="text" SUBFOLDERS="YES" OVERWRITE="YES" ONLYIFEXIST="YES/NO" MATCHCASE="YES/NO" EXCLUDE="text" RE="YES" SESSION="text" />

Related Topics

Description

Renames the files specified on the FTP server. This activity supports mutli-file renaming. To specify more than one file, use wildcards (for example, * or ? ). To specify multiple files or wildcard masks, separate them with a vertical bar (for example, *.txt|*.bak). See File Masks & Wildcards for more details.

NOTE: An FTP session is required to run this activity. Use the FTP Logon activity to create a session. Additionally, the files to rename must be located in the same folder and must be renamed in the same folder.

Practical usage

Renames one or more files during an established FTP session.

Parameters

Connection

Property Type Required Default Markup Description
Session Text Yes FTPSession SESSION="SessionName" Specifies the name of the originating session (created by a previous FTP - Logon step) in which to link this activity. This permits several FTP activities to be linked to a specific session, thus, allowing multiple simultaneous FTP operations to take place within a single task.  

File

Property Type Required Default Markup Description
Remote Files Text Yes (Empty)
  • SOURCE="/foldername/originalFilename.txt
  • SOURCE="/foldername/*.txt"
  • SOURCE="/folder/*.txt|/folder/*.doc"
  • SOURCE="originaFilename.txt
Indicates the files to rename. Enter the file names manually in the provided text box or click the folder icon to open the FTP Browser which allows connection to the server in order to browse available files and folders.

This can be a fully qualified UNIX style path and file name (preferred) or a single file (requires use of the FTP Change Folder action). Wildcards (for example, *.* or ?) may be used to rename files matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with the "|" symbol (for example, /*.txt|/*.doc). See File Masks & Wildcards for more details.

NOTE: Files with invalid paths are ignored at runtime.
New Name Text Yes (Empty)
  • DEST="/foldername/newFilename.txt
  • DEST="/foldername/*.txt"
  • DEST="/foldername/*.txt|/foldername/*.doc"
  • DEST="newFilename.txt
Specifies the new file names in which to rename the files specified in the Remote Files parameter.

File Options

Property Type Required Default Markup Description
Exclude mask Text No (Empty) EXCLUDE="*.txt" Causes this activity to omit any files matching the masks specified. Filenames or wildcard masks (for example, * or ?) may be used. Multiple entries may be specified by separating them with the"|" symbol (for example, *.txt|*.bak).
Regular expression Yes/No No No RE="YES" Specifies whether the value in the Exclude Mask parameter is a regular expressions. Regular Expression, also referred to as regex or regexp, provide a concise and flexible means for matching strings of text.
Include Subfolders Yes/No No No SUBFOLDERS="YES" When selected, specifies that, if present, subfolders should be searched for files matching the mask specified in the Remote Files parameter. The default value is NO.
Overwrite if exists Yes/No No No OVERWRITE="YES" When selected, specifies that, if files already exist in the destination, they should be overwritten. The default value is NO.
Only if exists in destination Yes/No No No ONLYIFEXIST="YES" When selected, denotes that only files that already exist in the destination will be copied from the source. All other files, regardless of whether they match the mask or other parameter settings will be bypassed. The default value is NO. Valid only if the Overwrite if exists parameter is selected.
Match case Yes/No No No MATCHCASE="YES" Indicates whether the properties set within this activity should be case sensitive in relation to the files to be renamed. The default value is NO.

Session Properties

Property Type Required Default Markup Description
Session Text Yes FTPSession SESSION="SessionName" Specifies the session name (created in a previous FTP - Logon step) that this activity should originate from. This permits several FTP activities to be linked to a specific session, thus, allowing multiple simultaneous FTP transfers to take place within a single task.  

Description

Error Causes

On Error

Additional notes

Variables and expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressingF2.

More on variables
More on expressions

More on the expression builder

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task renames files by way of FTP.

Copy
<AMFTP ACTIVITY="rename" SOURCE="/home/myFolder/originalFileName.txt" DEST="/home/myFolder/newFileName.txt" OVERWRITE="YES" SESSION="FtpSession1" />