Loop Files Action Icon

Loop Files Action

Declaration

<AMLOOPFILESFOLDER="text" RESULTVARIABLE="text [variablename]" ONLYFILENAME="yes/no" SUBFOLDERS="yes/no" FOLDERS="yes/no" FILES="yes/no" INCLUDE="text" EXCLUDE="text" SORT="text [options]">
  (block of steps to loop)
</AMLOOP>

See Also

Loop, End Loop, Loop Windows, Loop Processes, Loop Expression, Loop Dataset, Loop List, Break

Description

Loops through the filenames contained in the folder specified.  The variable specified in the Index parameter is updated with the current filename.  With each successive loop, the next filename is retrieved.  The loop ends after all the filenames have been retrieved or when a Break is encountered.

Practical Usage

To perform an action on every file and/or in a folder. This action is frequently used to perform actions on files in batches, such as resizing all image files in a folder.

Parameters

General Tab

Folder
Text, Required
MARKUP: FOLDER="C:\inetpub\ftproot\incoming"

Specifies the folder that should be scanned for files.

Result Variable
Text, Required
MARKUP: RESULTVARIABLE="varname"

Specifies an already created variable name that should be populated with the next filename on each successive loop.

Do not include path information
Yes/no, Optional (default: no)
MARKUP: ONLYFILENAME="yes"

If yes (checked), specifies that the path information (drive and folder name) should not be returned, only the filename will be returned. If no (default), the full path and filename will be returned.

Advanced Tab

Loop through subfolders
Yes/no, Optional (default: no)
MARKUP: SUBFOLDERS="yes"

If yes (checked), specifies that the loop will continue and include files/folders inside subfolders of the folder specified.

Include Mask
Text, Optional (default "*.*")
MARKUP: INCLUDE="*.txt"

Specifies the wildcard mask that should be included in the loop. For example, if *.txt was specified, the loop would only include files that have the extension .txt.

Exclude Mask
Text, Optional (default {blank} no exclude mask)
MARKUP: EXCLUDE="*.txt"

Specifies the wildcard mask that should be excluded from the loop. For example, if *.txt was specified, the loop would include all files except those that have the extension .txt.

Include Folders
Yes/no, Optional (default: no)
MARKUP: FOLDERS="yes"

If yes (checked), specifies that the will include folders as an item to loop. By default folders are not looped.

Include Files
Yes/no, Optional (default: YES)
MARKUP: FILES="yes"

If yes (checked), specifies that the will include files as an item to loop. By default, files are looped.

Output List
Text [options], Optional (default "none")
MARKUP: SORT="ascending"

Specifies whether a sort order should be applied to the values before the loop begins. For example, selecting "ascending" would return the files and/or folders in alphabetical order.

The Available Options Are:

none: The results are left in their natural order and not sorted.

ascending: The results sorted in ascending alphabetical order.

descending: The results sorted in descending alphabetical order.

Notes

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 by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...

More on expressions...

More on the expression builder...

Examples

<!---Play every MP3 file in the folder structure--->
<AMVARIABLE NAME="currentfile"></AMVARIABLE>
<AMLOOPFILES FOLDER="C:\mp3" RESULTVARIABLE="currentfile" SUBFOLDERS="YES">
<AMPLAYAUDIO FILE="%currentfile%">
</AMLOOP>