FTP - Delete

Declaration

<AMFTPDELETE SOURCE="text" EXCLUDE="text" SUBFOLDERS="yes/no" SESSION="text">

See Also

FTP Delete Action-Setting Properties, FTP Log On, FTP Upload, FTP Download, FTP Delete, FTP Rename, FTP Create Folder, FTP Remove Folder, FTP Change Folder, HTTP Post

Description

Deletes the file(s) specified from the FTP server. This activity allows deletion of multiple files. To specify more than one file, use wildcards (Example: * or ? ). To specify multiple files or wildcard masks, separate them with a vertical bar (Example: *.txt|*.bak).

Practical Usage

This activity can be used to delete files from the FTP server after they have been downloaded using the FTP Download activity.

Parameters

File Properties

Property
Type
Required
Default
Markup
Description

Remote File(s)

Text

Yes

(Empty)

a)SOURCE="/sourcefoldername/file.txt"
b)SOURCE="/sourcefoldername/*.txt"
c)SOURCE="/folder/*.txt|/folder/*.doc"
d)SOURCE="file.txt"

Indicates the file(s) 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 action). Wildcards (Example: *.* or ?) may be used to delete files matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with the pipe "|" symbol.

File Options Properties

Property
Type
Required
Default
Markup
Description

Include Subfolders

Yes/No

No

(Empty)

SUBFOLDERS="YES"

When set to YES, specifies that, if present, subfolders 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 (i.e. * or ?) may be used. Multiple entries may be specified by separating them with the"|" symbol (i.e. *.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.

Session Properties

Property
Type
Required
Default
Markup
Description

Session

Text

Yes

FTPSession

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.  

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties allows you to instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables and Functions

All text fields allow the use of expressions such as variables, functions or AutoMate extended functions, which can be entered by surrounding the expression in percentage signs (example: %FileDateTime(myVar)% or %myVar%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on function

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: This sample task will demonstrate how AutoMate 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(&quot;d&quot;, DateValue(FileList.FTPFileDate), Now())% &gt; 30">

          <AMFTP ACTIVITY="delete" SOURCE="%FileList.FTPFileName%" />

     </AMIF>

</AMLOOP>

<AMFTP ACTIVITY="logoff" />

 

↑ Top of Page