Filtering a list of files based on their name

If you have a requirement to loop through a directory and process all files with a specific name pattern, you can achieve this with the following operations:.

1) List Files: this operation return a list of objects.

2) Rename Table Columns: that’s the trick: the list is seen as a data table with one column and we give a name to the column: “file”

3) Filter Row on Expression Result: this operation will pass down all the records which meet the expression criteria. For example:


That’s it: the filtering is done. You can now add more operations on the selected files. For example:

4) Loop Through Set: this operation loops through each value within the list passed down from the above operation:
** - Set:** fileList
** - Current Item Name:** f

5) Get File Info
Within our loop we want to obtain the file name, not the full file path, to do this we use the Get File Info operation which returns several attributes about the file, one of them being Name:
** - File Path:** ${f.fileName}
NOTE: Above we are referencing the current file in the loop which we have named as ‘f’
** - Output Name:** fileInfo

6) Move/Rename File
Now we have full file path and the file name we can use the Move/Rename File operation to move the file to a new location and rename if desired.
** - Source Path:** ${f.fileName}
** - Target Path:** ./your_path/${fileInfo.Name}

1 Like