Loop Files Action

Description

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. Used to perform an action on every file in a folder. This action is frequently used to perform actions on files in batches, such as resizing all image files in a folder.

Declaration

<AMLOOP TYPE="FOLDER" FOLDER="text" RESULTVARIABLE="text [variablename]" ONLYFILENAME="yes/no" SUBFOLDERS="yes/no" FOLDERS="yes/no" FILES="yes/no" EXCLUDE="text" SORT="text [options]" ISNEWERTHAN="datetime" ISOLDERTHAN="datetime" SORTON="text [options]" ATTRFILTER="text [attribute mask]" RESULTDATASET="text">
  (block of steps to loop)
</AMLOOP>

Example

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

General Tab Parameters

Folder: Specifies the folder that should be scanned for files. Click the Expression Builder icon to build and insert an expression.

Text, Required
MARKUP: FOLDER="C:\FolderName\SubfolderName"

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

Text, Required
MARKUP: RESULTVARIABLE="varname"

Create and populate dataset with result information: Specifies the name of a dataset to be created and populated with the file data for the files in the folder. In addition to the standard dataset fields, the dataset will contain the following:

  • Name: the name of the file

  • Size: the file size

  • CreatedOn: the file creation date

  • ModifiedOn: the date the file was last modified

  • AccessedOn: the date the file was last accessed

  • IsFolder: yes/no—name is a folder  

  • IsReadOnly: yes/no—read-only attribute

  • IsArchive: yes/no—archive attribute

  • IsSystem: yes/no—system attribute

  • IsHidden: yes/no—hidden attribute

  • IsCompressed: yes/no—compressed

  • IsAccessible: yes/no—accessible

Text, Optional
MARKUP: RESULTDATASET="DatasetName"

Do not include path information: If YES (selected), specifies that only the file name and not the path information (drive and folder name) will be returned in the variable or dataset. If NO (default), the full path and file name will be returned.

Yes/no, Optional, Default: NO
MARKUP: ONLYFILENAME="yes"

Advanced Tab Parameters

Include mask: Specifies the wildcard mask that should be included in the loop. For example, if *.txt was specified, the loop would include all files that have the extension .txt. (* is specified by default.)

Text, Optional, Default: (blank)
MARKUP: EXCLUDE="*.txt"

Exclude mask: 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.

Text, Optional, Default: (blank)
MARKUP: EXCLUDE="*.txt"

Include subfolders: If YES (checked), specifies that the loop will include files or folders inside subfolders of the folder specified.

Yes/no, Optional, Default: NO
MARKUP: SUBFOLDERS="yes"

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

Yes/no, Optional, Default: NO
MARKUP: FOLDERS="yes"

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

Yes/no, Optional, Default: YES
MARKUP: FILES="yes"

Sorting: 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.

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

  • ascending: the results are sorted in ascending alphabetical order.

  • descending: the results are sorted in descending alphabetical order.

Text [options], Optional, Default: "none"
MARKUP: SORT="ascending"

Field to sort on: Specifies the field to use in sorting the files. Valid only if Sorting [SORT] is set to ascending or descending.

  • file_name: the file name

  • creationdate: the date the file was created

  • modificationdate: the date the file was last modified

  • size: the file size

Text [options], Optional, Default: (file name)
MARKUP: SORTON="size"

Date Filter Tab Parameters

Only if newer than: Causes the action to look only for files newer than the date/time specified. If this parameter is left blank or not included, the date of the files will be ignored (unless limited by the Only if older than [ISOLDERTHAN] parameter).

Date, Optional, Default: (none)
MARKUP: ISNEWERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Only if older than: Causes the action to look only for files older than the date/time specified. If this parameter is left blank or not included, the date of the files will be ignored (unless limited by the Only if newer than [ISNEWERTHAN] parameter).

Date, Optional, Default: (none)
MARKUP: ISOLDERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Click Custom to select from other time options (Last 30 seconds, Last 30 minutes, Last 24 hours, Last 30 Days, Last 12 Months, Last 5 Years, Next 30 Seconds, Next 30 Minutes, Next 24 Hours, Next 30 Days, Next 12 Months, Next 5 Years). A expression appears in the text box (e.g., %DateAdd( "s", -30, CStr( Now() ))%) and the Expression check box is selected.

Attributes Tab Parameters

Attributes: This group of settings causes the action to filter which files are processed based on the attribute settings of the source files. In visual mode, a group of controls is 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 process. The available options are:

  • 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 "+H" 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.

Text, Optional (blank)
MARKUP:
ATTRFILTER="+R+A-S-H" (move read-only and archive files, not system or hidden)
ATTRFILTER="-S" (do not move "system" files)