FTP - Delete file(s)
Declaration
<AMFTP ACTIVITY="delete" SOURCE="text" SUBFOLDERS="YES/NO" MATCHCASE="YES/NO" EXCLUDE="text" RE="YES/NO" TRAVERSALMODE="text (options)" SESSION="text" />
Description
Deletes the files specified from the FTP server. To specify more than one file, use wildcard characters (for example, * or ?). To specify multiple files or wildcard masks, separate them with a pipe character (for example, *.txt|*.bak). See File Masks & Wildcards for more details.
Practical usage
Can be used to delete files from the FTP server after they have been downloaded by the FTP - Download file(s) activity.
Parameters
Connection
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Session | Text | Yes | FTPSession1 | SESSION="SessionName" | Specifies the session name (created by a previous FTP - Logon step) where this activity originates. This permits several FTP activities to be linked to a specific session, allowing multiple simultaneous FTP transfers to take place within a single task. |
File
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Remote files | Text | Yes | (Empty) |
|
Indicates the files that reside in the FTP
server to delete. 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 activity). Wildcard characters (for example, *.* or ?) may be used to delete files matching a certain mask. Multiple files and/or file masks may be specified by separating the entries with the pipe character (|) . See File Masks & Wildcards for more details. NOTE: Files with invalid paths are ignored at runtime. |
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 pipe character (|) symbol (for example, *.txt|*.bak). |
Regular expression | Yes/No | No | No | RE="YES" | If selected, specifies that the value in the Exclude mask parameter is a regular expressions, also referred to as regex or regexp, which provides a concise and flexible means for matching strings of text. If disabled (default), the value is viewed as normal readable text. |
Include subfolders | Yes/No | No | (Empty) | SUBFOLDERS="YES" | If selected, specifies that any subfolders should be searched for files matching the mask specified in the Remote Files parameter (disabled by default). |
Match case | Yes/No | No | No | MATCHCASE="YES" | If selected, specifies the properties set within this activity are case sensitive in relation to the FTP server (disabled by default). |
Example
- 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 will demonstrate how Automate can delete files older than 30 days by way of FTP. The first step logs onto to an FTP server. Next, a "Get long file list" command using the FTP Advanced action populates a dataset with the file list results. A Loop - Dataset action loops through the dataset that holds the list of files and folders on the FTP server. Within the loop block of steps, an If action is used specifying the %DateDiff()% function, which gets a day differential between today's date and the date of the file on the FTP server. If the file is older than 30 days, it is deleted. If not, it is skipped. The last step logs off the FTP server.
<AMFTP ACTIVITY="logon" SERVER="YourFTPHost" USERNAME="YourUsername" PASSWORD="AM1NYGaQ+SuSz0MaN4SJbOlag==aME" SESSION="FtpSession1" />
<AMFTP ACTIVITY="advanced" FTPCOMMAND="long_list" PARAMETER="*.*" FTPLONGLISTDATASET="FileList" SESSION="FtpSession1" />
<AMLOOP ACTIVITY="dataset" DATASET="FileList"><AMIF EXPRESSION="%DateDiff("d", DateValue(FileList.FTPFileDate), Now())% > 30"><AMFTP ACTIVITY="delete" SOURCE="%FileList.FTPFileName%" SESSION="FtpSession1" /></AMIF></AMLOOP>
<AMIF EXPRESSION="%DateDiff("d", DateValue(FileList.FTPFileDate), Now())%" USECOMPLEXUI="YES" />
<AMFTP ACTIVITY="delete" SOURCE="%FileList.FTPFileName%" SESSION="FtpSession1" />
<AMIF ACTIVITY="end" />
<AMLOOP ACTIVITY="end" />
<AMFTP ACTIVITY="logoff" SESSION="FtpSession1" />