Delete File

Deletes the file or files specified. To specify more than one file, use wildcard characters (i.e. * or ?). Commonly used to automate the removal of one or more redundant or unnecessary files. You can permanently delete the files or send them to the Recycle Bin. You can also retrieve information about the deleted files for reporting purposes.

Declaration

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

Example 1 - This example deleted all files in "c:\folder1" to the recycle bin and creates and populate a dataset named "theDataset" with details of the file(s). A Loop Dataset action is then used to loop through the files that were deleted. Within each loop process, details about each deleted file (i.e. source location, result) is displayed in a message box.

<AMFILEDELETE SOURCE="c:\folder1\*.*" TORECYCLE="YES" RESULTDATASET="theDataset" />

<AMLOOP TYPE="DATASET" DATASET="theDataset">

<AMSHOWDIALOG WINDOWTITLE="Results of the delete operation.">The path and file name of the source file - %theDataset.Source%

The result of this operation - 0 for success - %theDataset.Result%

The textual information associated to the result - %theDataset.Message%</AMSHOWDIALOG>

</AMLOOP>

Example 2 - One line task that deletes all text files in a specified directory, including files found in any sub-directories.

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

See Also: Split File, Move File, Create Folder, Delete File, Delete Folder, Rename Folder, Remove Folder, Touch File, Set Attributes, Read from File, Write to File, Synchronize Folders, Concatenate Files, About Datasets

General Tab

Property

Type

Required

Default

Markup

Description

Source

Text

Yes

(Empty)

a)SOURCE="c:\foldername\file.txt"

b)SOURCE="c:\foldername\*.txt"

c)SOURCE="file.txt"

The path and file name of the file(s) 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 (i.e. * or ?) may be used to delete files matching a certain mask.

Place in Recycle Bin

Yes/No

No

No

TORECYCLE="YES"

If set to YES, deleted files are sent to the Recycle Bin. If set to NO (default), files are deleted permanently.

Create and Populate Dataset with Result Information

Text

No

(Empty)

RESULTDATASET="DatasetName"

Specifies the name of a dataset to be created and populated with information pertaining to this operation. More about datasets

Options Tab

Property

Type

Required

Default

Markup

Description

Include Subfolders

Yes/No

No

No

SUBFOLDERS="YES"

If set to YES, denotes that, if present, subfolders should be searched for files matching the mask specified in the Source parameter. If set to NO (default value), subfolders are ignored.

Exclude Mask

Text

No

(Empty)

ARCHIVETURNOFF="YES"

Causes this action to omit files matching the mask(s) specified. File names or wildcard masks may be used.

Only if Newer Than

Date

No

(Empty)

ISNEWERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

If enabled, causes this action to only act on files that are newer than the date/time specified. If this parameter is left blank or disabled (default), file dates are ignored.

Click Custom to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression.

Only if Older Than

Date

No

(Empty)

ISOLDERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

If enabled, causes this action to only act on files that are older than the date/time specified. If this parameter is left blank or disabled (default), file dates are ignored.

Click Custom to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression.

Attributes Tab

Property

Type

Required

Default

Markup

Description

Attributes

Text Options

No

(Empty)

ATTRFILTER="+R+A-H" (delete read-only & archive files but not hidden files)

This group of settings causes this action to filter which files are deleted based on the attribute settings of the source file(s). 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 want to delete. Available Options:

  • R— Read-only: Specifying "+R" causes files with this attribute turned on to be included, "-R" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • A— Archive: Specifying "+A" causes files with this attribute turned on to be included, "-A" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • S— System: Specifying "+S" causes files with this attribute turned on to be included, "-S" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • H— Hidden: Specifying "+R" causes files with this attribute turned on to be included, "-H" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • C— Compression: Specifying "+C" causes files with this attribute turned on to be included, "-C" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

Description Tab

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 Tab

The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.

More on Error Causes properties

On Error Tab

The On Error tab allows you to determine what the task should do if a particular step encounters an error.

More about On Error properties

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