The statement ForEach … Folder is used to process files in a folder.
Syntax
ForEach File
Folder "path\foldername"
Do
... ;
Od;
ForEach File This variable declared as Text. Common practice is to use File as variable name because it will contain the current File at each passing. Note that Directories in Folder are processed as well.Folder "path\foldername" Folder path and name. Each file in this folder will be processed in the part Do ... Od. This must be an
expression of type TEXT.... ; Repeating code
Every file in the folder is assigned to the variable File before the Do … Od is executed.
The command Break can be used to terminate the loop unconditionally.
Note
Any folders in the Folder set will also be processed. Please make sure that your code can handle directories as input.
Example
Var Text File;
Var Text ResultDirectory = C:\ITPResult;
ForEach File
Folder ResultDirectory
Do
If file_format(File) = "doc"
THEN
DoctoPDF
Src (File)
Dest (File[,"pdf"]);
Fi;
Od;
This will convert all Microsoft Word files in the c:\ITPResult directory to PDF.