Delete File Action

Declaration

<AMFILEDELETE SOURCE="text" SUBFOLDERS="yes/no" TORECYCLE="yes/no" ISNEWERTHAN="date" ISOLDERTHAN="date" EXCLUDE="text" ATTRFILTER="text" RESULTDATASET="Text" />

See Also

Delete File Action-Setting Properties, Copy File, Move File, Rename File, Delete Folder, Rename Folder

Description

Deletes the file or files specified. To specify more than one file use wildcard characters (* or ?). To specify multiple files or wildcard masks, separate them with a pipe symbol (|). Example: c:\*.txt|c:\*.bak

Practical Usage

Used to delete one or more files.

Parameters

General Tab

Source

Text, Required
MARKUP:
a) SOURCE="c:\sourcefoldername\file.txt"
b) SOURCE="c:\sourcefoldername\*.txt"
c) SOURCE="C:\sourcefoldername\*.txt|C:\sourcefoldername\*.doc"
d) SOURCE="file.txt"

Specifies the files to delete. This can be a fully qualified path and file name (preferred) or a file name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to delete files matching a certain mask. Multiple files and file masks may be specified by separating the entries with a pipe symbol (|).

Place in Recycle Bin

Yes/No, Optional, Default: NO
MARKUP: TORECYCLE="YES"

Specifies whether to permanently delete the files or send them to the Recycle bin.

Create and Populate Dataset with Result Information

Text, Optional
MARKUP: RESULTDATASET="DatasetName"

Specifies the name of a dataset to be created and populated with the result. In addition to the standard dataset fields, the dataset will contain the following:

Options Tab

Include Subfolders

Yes/No, Optional, Default: NO
MARKUP: SUBFOLDERS="YES"

When set to YES, specifies that, if present, subfolders should be searched for files matching the mask specified in the Source [SOURCE] parameter

Exclude Mask

Text, Optional, Default: (blank)
MARKUP: EXCLUDE="*.txt"

Causes the action to not delete files matching the masks specified. Filenames or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|), for example: *.txt|*.bak

Only if Newer Than

Date, Optional, Default: (none)
MARKUP: ISNEWERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Causes the action to only delete files if the source is newer than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (unless limited by the Only if older than [ISOLDERTHAN] parameter).

Only if Older Than

Date, Optional, Default: (none)
MARKUP: ISOLDERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Causes the action to only delete files if the source is older than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (unless limited by the Only if newer than [ISNEWERTHAN] parameter).

Attributes Tab

Attributes

Text, Optional (blank)
MARKUP:
ATTRFILTER="+R+A-S-H" (delete read-only and archive files, not system or hidden)
ATTRFILTER="-S" (do not delete "system" files)

This group of settings causes the action to filter which files are deleted based on the attribute settings of the source files.

In visual mode, a group of controls are provided to assist in the selection of this parameter. In markup mode, a single text item must be specified that contains the attributes of the files you wish to delete.

Available Options:

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

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 pressing F2.

More on variables
More on expressions

More on the expression builder

Examples

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

<AMFILEDELETE SOURCE="c:\folder1\*.*" />

<AMFILEDELETE SOURCE="c:\folder1\*.*" SUBFOLDERS="YES" ATTRFILTER="+r+a" RESULTDATASET="DeletionDS" />

<AMFILEDELETE SOURCE="c:\folder1\*.*" SUBFOLDERS="YES" SNEWERTHAN="%DateSerial(2007,02,01) + TimeSerial(20,42,51)%" RESULTDATASET="DeletionDS" />