I've done this kind of thing in the past so I can offer you an approach that hopefully you'll find useful.
There are two different macros involved.
The first is a general purpose subroutine that simply reads lines from files. If you look at it, it contains usage information in the command. You need to download this and install it as you normally would for any macro; there is no need to modify this subroutine at all.
Download Macro(s): [SUB] Get Chunks From List.kmmacros (52 KB)
Macro-Notes
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information
- macOS 10.14.6
- Keyboard Maestro v10.2
The second macro is the one that does the hard work. Here it is:
Download Macro(s): Test Process Files.kmmacros (17 KB)
Macro-Notes
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information
- macOS 10.14.6
- Keyboard Maestro v10.2
Once you've installed this macro you'll need to make some changes to it in order to get it to actually do what you want. All the places you need to make changes are coloured red.
- The first red action sets a KM variable called Local__TextFiles You need to put the paths to your text files into this variable. As it stands, I've set it to 5 text files in a folder on my Desktop for testing purposes.
- There are 5 other places you need to make changes. At each one you need to change "contains File 1" or "contains File 2" etc to reflect the file names you have chosen for your text files; you might use a simple naming convention like I have or it might be more complicated. IMHO - simple is better!! Also at each one, you need to add some KM macro actions in order to perform whatever you need to do to those URLs - the text of which is held in the variable Local__LineFromFile.
If you need more than 5 text files you can expand the Switch
action accordingly. Similarly, if you need lest than 5, just deleted the ones you don't need.
Finally, I haven't set a trigger for this macro - I'll leave that for you to decide.