Read a File if it meets certain requirements

I want to read a file to the system clipboard if it meets certain requirements. So far I have For each item in a collection execute actions. This is set to the files in a directory. I then have get file name to a variable which I have named FileName. The next action is an if/then else set to all of the following are true: The variable FileName contains dnld. Under execute the following actions, I am trying to use read file to system clipboard. This won't work because it wants me to tell it what file to read, which I think I already have by nesting this execution after the above. My human wording summary is : grab a file from a directory and set its file name to a variable, which if that variable contains dnld then read the file to the system clipboard.

What am I ultimately trying to do?

I want keyboard maestro to look in certain files and ocr their contents so that it can rename the file from certain elements inside the file. My material suppliers send me invoices with ridiculous file names. dnld234445435467896ghr.pdf etc. This means nothing to me. I want to pull customer name and address out of the invoice text and make that the filename. I only want to run the macro successfully on files with those ridiculous file names. Since the macro will be set to run on all files in that folder, I need the if/then else so that it skips files already processed. I want to use conditions to automate the reading of the file to the system clipboard. I just don't know how to tell KM to read the file that is already at the center of KM's attention.

It sounds like you're most of the way there with your current macro. You probably just need to use the variable that contains the path to the current file in the For Each loop in the Read File action, like this:

Example Macro.kmmacros (2.8 KB)

Thanks. I will work on that.