
This statement allows you to enumerate items. A specified action is successively called for each enumerated value. There are four modes available.
Each time the action is called a single list item is supplied in a track or named variable. The list is obtained from a field or named variable. When a named variable is used the name field may contain any of the escape sequences described in Escape Sequences
The delimiter can take two forms:
When the delimiter is empty, regardless of the type, every field is treated as a single item. Example: If running stepwise with the Artist field and no delimiter, the effective list will be all unique Artist fields.
There are four modes which determine how and if the list is constructed and the order in which list elements are passed to the action:
The execution profile is as follows:
When Run Grouped is selected, you can choose to run the action only once. The effect is that only a single file is processed. This is useful when the repeated action is processing data which is independent of the metadata in the tracks. For example you might be processing a query database or a list. This combination of options is similar to the Constrain Execution to a Single File statement.
Note that if the designated action contains a Force Grouped statement, it is equivalent to specifying the Run grouped option.
Note also, that regardless of the execution mode, an Exit Repeat statement will terminate all repeating.
The statement can specify that the named action is inline. When Inline is specified there must be a Start statement inside the current action with the specified name.
The Indirect option enables the use of Escape Sequences in the text field where you specify the name of the action to be run. This enables you to choose the action to be run based on the contents of track variables or any other constructed pattern. The action name is only validated at run time. If the evaluated name is empty, the Repeat With statement is ignored. You can setup lists using the various list statements to contain the names of actions; inline or not. By using the List Item At Index/Sublist statement, you can pull an action name and place it in a track variable which can then be specified in the Repeat With statement. Note that escape sequences are only evaluated once. You cannot use a single statement to call multiple actions.
Note that changing the list or source string's contents once the Repeat With statement is started, will have no effect on the loop's execution. Changing the value of the current track or named variable's contents will also have no effect on subsequent iterations. The effective list is only calculated once per set of files. Unless the initial list items are in a named variable, you more than likely want to run grouped.
Example:
Repeat With Variable 1 for the list in field Genre (Sorted) string delimiter "\~" Run inline action 'test'
If all the files have a Genre field of Blues, Blues Rock, Rock, action test will be successively called with Variable 1 set to Blues, then Blues Rock, then Rock.
When enumerating by characters, a designated action is successively called with a single character in a specified track or named variable. The list string is obtained from a field or named variable. When run stepwise and a field is specified, the effective contents are evaluated once, based on the first selected file.
The execution profile is the same as above. Simply replace list item with a single character
Example:
Set named variable 'delims' to "ABC" Repeat With named variable 'code' for every character in named variable 'delims' Run inline action 'test' grouped
As grouped is specified, each active file will be called with Code equal to A, then with code equal to B, then with code equal to C.
This mode is used when you want to execute an action for at most a single value at a time. In this mode you specify a field or track variables. The specified action is called once for each unique value. You cannot specify grouped, however the mode will work while executing grouped.
You can specify case and diacritic insensitivity when determining uniqeness. You can also specify that leading and trailing spaces are to be ignored. Further, you can optionally specify that empty values (possibly after ignoring leading and trailing spaces) and values where the text has a leading integer value of zero, are to be ignored.
When the action is called, the list of active files will be changed to guarantee that each file contains the unique value in the specified field or track variable.
Example:
Repeat With active files based on field Album (case, space insensitive, ignore empty) Run inline action 'test'
Inline action test will be called for each unique Album field. The values are case and leading/trailing space insensitive. The action will not be called for files with an empty Album field.
Quite often you want to process folders one at a time. This mode is a convenience mode.
Repeat With active files based on path to folder Run inline action 'test'
is the same as the following:
Get Property Path to Folder -> Variable 0 Repeat With active files based on Variable 0 Run inline action 'test'
If you change the file availability while executing with this statement in the List Items or Characters modes, make sure you restore the active files to those available when the statement was started. If you do not, the execution flow may be unpredictable. This does not apply with the Field Values or Path to Folder modes. These modes always restore the initial set of activate files as does the if - else - endif modes which constrain the set of active files.