Delete Action Icon

Delete File

Declaration

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

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

File System - Delete

Declaration

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

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

Description

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

Practical Usage

Commonly used to automate the removal of one or more redundant or unnecessary folders, files or complete directories. You can permanently delete folders/files or send them to the Recycle Bin. You can also retrieve information about the deleted folders/files for reporting purposes.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

File/Folder

Text (Options)

Yes

File

MODE="folder"

Indicates what this activity should be performed on. The available options are:

  • File (default) -  This activity should be performed on file(s). A file is the common storage unit in a computer. All programs and data are contained in a file, and the computer reads and writes files.

  • Folder - This activity should be performed on folder(s). A folder holds one or more files, although a folder can also be empty. Folders provide a method for organizing files similar to a manila file folder containing paper documents in a file cabinet.

Different parameters may become available depending on which option is selected.

Source

Text

Yes

(Empty)

  1. SOURCE="c:\sourcefolder\file.txt"

  2. SOURCE="c:\sourcefolder\*.txt"

  3. SOURCE="c:\folder\*.txt|c:\folder\*.bak"

  4. SOURCE="c:\foldername\subfoldername

The path of the folder(s) or path and file name of the file(s) to delete. This can be a fully qualified path and folder/file name (preferred) or a folder/file name only (requires use of the Change Folder action). Wildcard characters (i.e. * or ?) may be used to delete folders/files matching a certain mask. Multiple files and file masks may be specified by separating each entry with a pipe symbol (i.e. c:\*.txt|c:\*.bak).

Place in Recycle Bin

Yes/No

No

No

TORECYCLE="YES"

If set to YES, deleted folders/files are sent to the Recycle Bin. If set to NO (default), folders/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 the folders/files that were operated on. More about the dataset that this action creates can be found below under Notes.

 

File Options Properties

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 folders/files matching the mask(s) specified. Folder/File names or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|), for example: *.txt|*.bak

Regular Expression

Yes/No

No

No

RE="Yes"

If set to YES, specifies that the data entered under the Exclude Mask field is a regular expression. Set to NO by default.

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 folders/files that are newer than the date/time specified. If this parameter is left blank or disabled (default), folder/file dates are ignored.

Click the Custom button 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 folders/files that are older than the date/time specified. If this parameter is left blank or disabled (default), folders/file dates are ignored.

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

 

File Filters Properties

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 wish 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 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 allows you to select/omit specific errors that should cause a particular step to fail.

More on Error Causes properties

On Error Properties

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

Notes

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields. The table below describes these fields (assuming the dataset name assigned was theDataset).

Name

Type

Return Value

theDataset.Source

Text

The path and file name of the source folder/ file.

theDataset.Size

Number

The size of the folder/file (in kb).

theDataset.Destination

Text

The path and file name of the destination file.

theDataset.Result

True/False

Returns TRUE if result of activity is a success, otherwise, returns a FALSE.

theDataset.Message

Text

The textual information associated to the result.

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

Example

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

 

Example 1 - This sample task 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" />

 

↑ Top of Page