Sometimes, you may want to repeat one or more actions, for every item contained in a list. Either you want to use every item of an Excel row, or every line of a text file, you will have to deal with lists. In order to use every item of a specific list for a predefined set of actions, you will have to use a “For Each” loop (”For Each” action under “Loops” category).
A “For Each” loop, iterates through every item of a list and stores the current item in a variable. This kind of loop is extremely useful when you do not know or you do not need to know the number of the iterations that will be needed, but you do want to iterate through every item of a list and use each one of them in an action (or a series of actions).
Example:
You may want to retrieve the filenames of every .mp3 file in your D:\ disk. In this case, your job should look like this:
1) Get Files in Folder (D:\ , including subfolders) and store them in %MyMp3Files%
2) For Each (item contained in %MyMp3Files% and store current item in %CurrentMp3%)
3) Write text to file (append to C:\MyMp3Files.txt): %CurrentMp3.Name%
4) End Loop
Post new comment