How can I search files inside a directory with a "For Each File" step?


Please refer to the information below.

(Example) Only searching and looping through ".txt" files in the "bizrobo_test" folder which contains both ".txt" and ".xlsx" files.

▼Inside this folder


 ▼Action tab of the "For Each File" step



Directory Name
Set the directory to loop through
(Example) c:\bizrobo_test

Include Subdirectories
If checked, the files of sub-directories (and all levels below) under the set directory will be included. If unchecked, only the files directly under the set directory will be included.

File Name Pattern
Only the file(s) that has/have a name matching the entered pattern will be included.
(Example) .*.txt
Please refer to "How to extract characters by pattern in DS?", for a method to describe patterns.


Store File Names Here
Set a variable to register the name (or path) of the current file at each iteration.
(Example) file_name



Executing a "For Each File" step with the above settings, will give the "file_name" variable the values below.

First loop:「c:\bizrobo_test\01.txt.txt」



 Second loop:「c:\bizrobo_test\02.txt.txt」



Third loop:「c:\bizrobo_test\03.txt.txt」



You can see that only the ".txt" files of the "bizrobo_test" folder have been looped through.



"The Step could not be reached. The For Each File action did not find any files."

If this error message appears when using a "For Each File" step, please refer to "For loop steps such as "For Each File", the "Try Next Alternative" setting is not performed and an error occurs".

4 out of 4 found this helpful



Article is closed for comments.