FTP - Delete
Declaration
<AMFTPDELETE SOURCE="text" EXCLUDE="text" SUBFOLDERS="yes/no" SESSION="text">
Description: Deletes the file(s) specified from the FTP server. To specify more than one file, use wildcard characters (* or ? ). To specify multiple files or wildcard masks, separate them with a vertical bar (*.txt|*.bak).
Practical Usage
Can be used to delete files from the FTP server after they have been downloaded by the FTP - Download activity.
Session Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Session |
Text |
Yes |
FTPSession1 |
SESSION="SessionName" |
Specifies the session name (created in a previous FTP Log On 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. |
File Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Remote file(s) |
Text |
Yes |
(Empty) |
|
Indicates the file(s) that reside in the FTP server to delete. This can be a fully qualified UNIX style path and filename (preferred) or a single file (requires use of the FTP - Change folder sctivity). Wildcard characters (e.g., *.* 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 "|" symbol. |
File Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Include subfolders |
Yes/No |
No |
(Empty) |
SUBFOLDERS="YES" |
If set to YES, specifies that, if present, sub-folders should be searched for files matching the mask specified in the Remote Files parameter. The default value is NO. |
Match case |
Yes/No |
No |
No |
MATCHCASE="YES" |
Indicates whether the properties set within this activity should be case sensitive in relation to the FTP server. The default value is NO. |
Exclude mask |
Text |
No |
(Empty) |
EXCLUDE="*.txt" |
Causes this activity to omit any files matching the mask(s) specified. Filenames or wildcard masks (e.g., * or ?) may be used. Multiple entries may be specified by separating them with the"|" symbol (e.g., *.txt|*.bak). |
Regular expression |
Yes/No |
No |
No |
RE="YES" |
If set to YES, 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 set to NO (default), the value is viewed as normal readable text. |
Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.
Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)
On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)
Example
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Description: This sample task will demonstrate how can delete files older than 30 days via 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. In order for this task to work in your environment, please make the appropriate modifications in the properties of each activity.
<AMFTP ACTIVITY="logon" SERVER="YourFTPHost" USERNAME="YourUsername" PASSWORD="AM1NYGaQ+SuSz0MaN4SJbOlag==aME" /> <AMFTP ACTIVITY="advanced" FTPCOMMAND="long_list" PARAMETER="*.*" FTPLONGLISTDATASET="FileList" /> <AMLOOP TYPE="DATASET" DATASET="FileList"> <AMIF EXPRESSION="%DateDiff("d", DateValue(FileList.FTPFileDate), Now())% > 30"> <AMFTP ACTIVITY="delete" SOURCE="%FileList.FTPFileName%" /> </AMIF> </AMLOOP> <AMFTP ACTIVITY="logoff" /> |