FTP - Delete file(s)

Declaration

<AMFTP ACTIVITY="delete" SOURCE="text" SUBFOLDERS="YES/NO" MATCHCASE="YES/NO" EXCLUDE="text" RE="YES/NO" SESSION="text" />

Related Topics   

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).

NOTE: An FTP session is required to run this activity. Use the FTP Logon activity to create a session.

Practical Usage

Can be used to delete files from the FTP server after they have been downloaded by the FTP - Download activity.

Parameters

Connection

Property

Type

Required

Default

Markup

Description

Session

Text

Yes

FTPSession1

SESSION="SessionName"

Specifies the session name (created by 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 operations to take place within a single task.  

File

Property

Type

Required

Default

Markup

Description

Remote file(s)

Text

Yes

(Empty)

  1. SOURCE="/sourcefoldername/file.txt"

  2. SOURCE="/sourcefoldername/*.txt"

  3. SOURCE="/folder/*.txt|/folder/*.doc"

  4. SOURCE="file.txt"

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 activity). Wildcard characters (i.e. *.* 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. See File Masks & Wildcards for more details.

File Options

Property

Type

Required

Default

Markup

Description

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"

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.

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.

 

Description

Error Causes

On Error

Example

NOTE: 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 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" />