|
File System - Delete |
Declaration
<AMFILESYSTEM ACTIVITY="delete" MODE="text (options)" SOURCE="text" TORECYCLE="YES/NO" RESULTDATASET="text" SUBFOLDERS="YES/NO" EXCLUDE="text" RE="YES/NO" ISNEWERTHAN="%DateSerial+TimeSerial%" ISOLDERTHAN="%DateSerial+TimeSerial%" ATTRFILTER="+r-a-s-h+c+e" />
Description
Deletes the files or folders specified. To specify more than one file/folder, use wildcard characters (for example, * or ?). To specify multiple files or wildcard masks, separate them with a pipe symbol (for example, c:\*.txt|c:\*.bak).
Practical Usage
Commonly used for batch removal of redundant or unnecessary folders, files or system 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
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
File/Folder | Text (Options) | Yes | File | MODE="folder" |
Indicates the type of items to delete. Parameters located in the File options section vary depending on which option is selected. The available options are:
|
Source |
Text |
Yes |
(Empty) |
|
The path of the folders or files to delete. This can be a fully qualified path and file name (preferred) or a single file (requires use of the File System - Change folder activity). Wildcard characters (for example, * or ?) may be used to specify all files matching a certain mask. Multiple files and/or file masks can be specified by separating each entry with a pipe character (|) (for example, c:\temp\*.txt|c:\backup\*.bak). See File Masks & Wildcards for more details. NOTE: Files with invalid paths are ignored at runtime.
|
Place in Recycle Bin | Yes/No | No | No | TORECYCLE="YES" | If selected, folders/files are sent to the Recycle Bin. If disabled (default), folders/files are deleted permanently. |
Create and populate dataset with results | Text | No | (Empty) | RESULTDATASET="DatasetName" | The name of a dataset to create and populate with information pertaining to results of this operation. More about the individual dataset fields that this activity creates can be found below under Datasets. |
File Options
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Include subfolders | Yes/No | No | No | SUBFOLDERS="YES" | If selected, denotes that, if present, subfolders should be searched for files matching the mask specified in the Source parameter. If disabled (default), subfolders are ignored. |
Exclude mask | Text | No | (Empty) |
|
Causes this activity to omit deleting folders/files matching the masks specified. Wildcard masks (for example, * or ?) 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 selected, indicates that any value entered in the Exclude mask parameter will be interpreted as a regular expression. If disabled (default) the value will be interpreted as normal readable text. |
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 Filter
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Attributes | Text (options) | No | Doesn't matter | ATTRFILTER="+R+A-H" (compress read-only & archive files but not hidden files) | Instructs
the activity to filter which files to act on, based on whether
the file's original attribute settings match the attribute settings
specified in this parameter. In Task Builder's visual mode, drop-down boxes are provided within the activity's settings
to assist in the selection of attribute settings. In Task Builder's AML mode,
a text item must be entered that contains the original
attribute mask of the files you wish to affect. For example, if Read-only
attribute is set to Off
(in visual mode) or -R (in AML mode) , only source files with the Read-only attribute
turned off are affected. Source files with Read-only attribute turned
on will be ignored. The available options
are:
|
Additional 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. |
Examples
- The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
- Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.
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 files. 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.
<AMFILESYSTEM ACTIVITY="delete" SOURCE="c:\folder1\*.*" TORECYCLE="YES" RESULTDATASET="the Dataset" />
<AMLOOP ACTIVITY="dataset" DATASET="the Dataset" />
<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 ACTIVITY="end" />
Example 2
This sample one line task that deletes all text files in a specified directory, including files found in any sub-directories.
<AMFILESYSTEM ACTIVITY="delete" SOURCE="c:\folder1\*.*" RESULTDATASET="the Dataset" SUBFOLDERS="YES" />