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
In the Available Actions pane, open the Loop folder and double-click the Loop Files action or drag it into the Steps pane.
In the Folder box, click Open Folder and navigate to the folder that contains the files.
In the Populate variable with file name box, select the variable to populate.
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.
If you want to use only the file names without the paths, select Do not include path information.
To set additional masks and specifications for the file selection, click the Advanced tab, and enter the properties as follows:
To include files within subfolders, select Loop through subfolders.
Use either the Include mask or the Exclude mask box to enter all or part of the file names that you want to include or ignore. If you make entries in the Include mask box, all files that do not match your entries will be ignored. If you make entries in the Exclude mask box, only the specified files will be ignored and all others will be included. You can use asterisk (*) and question mark (?) as wildcard characters.
If you want to perform the action on folders as well as files, select Include folders. If you want to perform the action only on folders and not on files, clear the Include files check box.
If you want the files looped in ascending or descending alphabetical order, make your selection in the Sorting box. By default files are looped in the order they appear in the folder.
To set the Description tab properties, refer to Description Tab Options.
To set the Error Causes and On Error tab properties, refer to Step Error Handling.
When finished, click OK to save settings and close the properties dialog box.
To auto-indent after all steps are added
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.
Click Format .
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. |
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:
|
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:
|
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. |
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:
|
This action includes the Description tab for entering a custom step description.
More on setting custom step description
This action also includes the standard Error Causes and On Error failure handling options/tabs.
More on Error Handling Options
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.