I'm trying to have a macro run consecutive scripts on all files in a directory. I don't seem smart enough to make this happen. Also, I would like it to generate a intermediate file that appends an index to the intermediate output file name (like "timeslips.1.csv timeslips.n.csv"
Please help me. I've tried just about everything I know how to do. Incidentally, the scripts themselves to operate appropriately in KM. It's just fixing the ForEach loop that I need help with.
Thanks!
Invoice Conversion - hourly - folder.kmmacros (3.2 KB)

There is clearly a lot of confusion going on.
The For Each action will set the “File Name” variable to the full path of the first file in the folder, run the actions, then set it to the path of the second file, run the actions, etc.
There is no such token as %Path%. So that would be equivalent of %Variable%Path% which has nothing to do with this macro.
There is no such token as %Trigger%. So again, that would reference the variable named “Trigger”, which has nothing to do with this macro.
Also, %Variable%Index% is referencing the variable named “Index”, which has nothing to do with this macro.
In your script “$KMVAR_File_Name” would be appropriate4 and would reference the file in the directory.
I don’t understand what you want the output file to be named.
If you want a numeric index, you will need to set a variable to 1 at the start, and then add one each time in the loop.
- Set variable “Index” to 1
- For Each …
- …
- Use %Variable%Index% in a text field.
- Set variable “Index” to calculation “Index + 1”