Loop Files

Loops through the file names contained in the folder specified. The variable specified is updated with the current file name. With each successive loop, the next file name is retrieved. The loop ends after all the file names have been retrieved or when a Break is encountered. This action accepts wildcards (* and ?). Ideally used to perform an action on every file in a folder or perform actions on files in batches, such as re-sizing all image files in a folder.

This action creates a dataset with the following fields (assuming the name of the dataset is theDataset):

Name

Data Type

Return Value

theDataset.Name

Text

Returns the name of the file.

theDataset.Size

Number

Returns the file size.

theDataset.CreatedOn

Date

Returns the file creation date.

theDataset.ModifiedOn

Date

Returns the date the file was last modified.

theDataset.AccessedOn

Date

Returns the date the file was last accessed.

theDataset.IsFolder

Yes/No

Returns whether the file name is a folder (yes/no).

theDataset.IsReadOnly

Yes/No

Returns whether the file attribute is read-only (yes/no).

theDataset.IsArchive

Yes/No

Returns whether the file attribute is archive (yes/no).

theDataset.IsSystem

Yes/No

Returns whether the file attribute is system (yes/no).

theDataset.IsHidden

Yes/No

Returns whether the file attribute is hidden (yes/no).

theDataset.IsCompressed

Yes/No

Returns whether the file is compressed (yes/no).

theDataset.IsAccessible

Yes/No

Returns whether the file is accessible (yes/no).

Declaration

<AMLOOP TYPE="FOLDER" FOLDER="text" ONLYFILENAME="Yes/No" SUBFOLDERS="Yes/No" EXCLUDE="text" SORT="test(options)" ISNEWERTHAN="date" ATTRFILTER="text" RESULTDATASET="text">

See Also: Loop, End Loop, Loop Array, Loop Windows, Loop Expression, Loop Dataset, Loop List, Loop List Control, Loop Tree Control, About Datasets

To set Loop Files properties

  1. In the Available Actions pane, open the Loop folder and double-click the Loop Files action or drag it into the Steps pane.

  2. In the Folder box, click Open Folder and navigate to the folder that contains the files.

  3. In the Populate variable with file name box, select the variable to populate.

  4. To populate a dataset with the file data, enter a name for the dataset in the Create and populate dataset with result information box. (Dataset names must be alphanumeric, begin with a letter, and contain no spaces.)

    The dataset will show the file's name, size, date created, date modified, date last accessed, plus the state of various attributes.

  5. If you want to use only the file names without the paths, select Do not include path information.

  6. To set additional masks and specifications for the file selection, click the Advanced tab, and enter the properties as follows:

  7. To set the Description tab properties, refer to Description Tab Options.

  8. To set the Error Causes and On Error tab properties, refer to Step Error Handling.

  9. When finished, click OK to save settings and close the properties dialog box.

To auto-indent after all steps are added

  1. In the Steps pane, hold down SHIFT and click the first and last steps in the block so that the complete block of steps is selected.

  2. Click Format .

General Tab

Property

Type

Required

Default

Markup

Description

Folder

Text

Yes

While

C:\FolderName\SubfolderName"

The folder that should be scanned for files. This parameter also acts as an Include Filter and accepts wildcard characters such as * and ?.

Populate variable with file data

Text

Yes

(Empty)

RESULTVARIABLE="varname"

The name of the variable that should be populated with the next file name on each successive loop.

Create and populate dataset with result info

Text

No

(Empty)

RESULTDATASET="DatasetName"

The name of a dataset to be created and populated with specific information regarding the files being looped through. About Datasets

Do not include path info

Yes/No

No

No

ONLYFILENAME="yes"

If set to YES (enabled), only the file name and not the path information (drive and folder name) will be returned in the variable or dataset. If set to NO (default), the full path and file name will be returned.

Advanced Tab

Property

Type

Required

Default

Markup

Description

Exclude Mask

Text

No

(Empty)

EXCLUDE="*.txt"

Indicates a wildcard mask to designate files that should be omitted from the loop. Asterisk (*) or question mark (?) can be used as wildcard characters. For example, if *notepad* was specified, the loop would ignore file that included the text notepad in its name.

Include Subfolders

Yes/No

No

No

SUBFOLDERS="yes"

If set to YES (or enabled), specifies that the loop will include files or folders inside subfolders of the folder specified. By default, subfolders are not included.

Include Folders

Yes/No

No

No

FOLDERS="yes"

If set to YES (or enabled), specifies that the loop will include folders as an item to loop. By default folders are not looped.

Include Files

Yes/No

No

Yes

FILES="yes"

If set to YES, specifies that the loop will include files as an item to loop. By default, files are looped.

Sorting

Text (options)

No

Do not sort list

SORT="ascending"

Specifies whether a sort order should be applied towards the list of processes before the loop begins. The available options are:

  • Do not sort list (default)

  • Sort the list in ascending alphabetical order

  • Sort the list in descending alphabetical order

Field to sort on

Text (options)

No

File Name

SORTON="size"

The field to use in sorting the files. Valid only if the Sorting parameter is set to Ascending or Descending. The available options are:

  • File Name: The name of the file.

  • CDate Created: The date the file was created.

  • Date Modified: The date the file was last modified.

  • File Size: The size of the file.

Date Filter Tab

Property

Type

Required

Default

Markup

Description

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" (copy read-only & archive files but not hidden files)

This group of settings causes this action to filter which files are affected by the attribute change based on the original attribute settings of the source files.

In visual mode, a group of controls are provided to assist in the selection of this parameter. In AML mode, a single text item must be specified that contains the original attribute mask of the files you want to affect.

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

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

See Also

About Actions

Adding Task Steps