Combining PDFs using Automator and Hazel

I need some help using an automator script with Hazel.
The basic problem seems to be how to take two pdf files and combine them using automator and Hazel.
Description:
I receive a receipt (pdf) for a regular payment that doesn’t have any identification of the vendor. So I thought one way to solve this problem ,so that Hazel could file the receipt, was to add a second sheet with the name of the vendor.
Accordingly I created a automator script to combine the two documents and rename the resulting file.
This worked as expected.
In order to automate the process I want to run the automator routine from Hazel. This has proved to be a challenge. It seems whatever I do, details following, Hazel wants to execute the Automator routine at least twice. So that instead of a two page document I end up with a four page document.
I’ve tried configuring Hazel a number of ways to get this work but I always end up with duplicates of what I want.
Some examples
Hazel checks to see if there is a file in the appropriate folder. If there is then it should run the Automator routine. I concluded that this didn’t work in the first iteration because once the routine finished running there were still files in the folder and so the routine ran again.
One Version
To counter this I expanded the Automator routine to move all the files out of the target folder. Once again the Automator routine works but when I run it from Hazel I get a document with three pages instead of two.
For some reason it seemed as though Hazel was re-running the automator routine before it had ended. I’m sure this is cockpit error but I couldn’t understand what was happening.
It occurred to me that perhaps we need to tell the automator routine to stop executing but I couldn’t see a way to accomplish this type of ‘stop execution’ in Hazel.
An alternative approach I tried was to monitor the number of files in the folder and if it is not exactly two then then Hazel doesn’t execute but that didn’t work either. It produced more duplication so that I ended up with multiple new files instead of one.
Hazel monitoring the number of sub-files
One version of the automator routine
I'd appreciate any suggestions/ help in solving this problem. Seems that being able to combine two pdfs would be useful general function for Hazel.
Thanks.
The basic problem seems to be how to take two pdf files and combine them using automator and Hazel.
Description:
I receive a receipt (pdf) for a regular payment that doesn’t have any identification of the vendor. So I thought one way to solve this problem ,so that Hazel could file the receipt, was to add a second sheet with the name of the vendor.
Accordingly I created a automator script to combine the two documents and rename the resulting file.
This worked as expected.
In order to automate the process I want to run the automator routine from Hazel. This has proved to be a challenge. It seems whatever I do, details following, Hazel wants to execute the Automator routine at least twice. So that instead of a two page document I end up with a four page document.
I’ve tried configuring Hazel a number of ways to get this work but I always end up with duplicates of what I want.
Some examples
Hazel checks to see if there is a file in the appropriate folder. If there is then it should run the Automator routine. I concluded that this didn’t work in the first iteration because once the routine finished running there were still files in the folder and so the routine ran again.
One Version
To counter this I expanded the Automator routine to move all the files out of the target folder. Once again the Automator routine works but when I run it from Hazel I get a document with three pages instead of two.
For some reason it seemed as though Hazel was re-running the automator routine before it had ended. I’m sure this is cockpit error but I couldn’t understand what was happening.
It occurred to me that perhaps we need to tell the automator routine to stop executing but I couldn’t see a way to accomplish this type of ‘stop execution’ in Hazel.
An alternative approach I tried was to monitor the number of files in the folder and if it is not exactly two then then Hazel doesn’t execute but that didn’t work either. It produced more duplication so that I ended up with multiple new files instead of one.
Hazel monitoring the number of sub-files
One version of the automator routine
I'd appreciate any suggestions/ help in solving this problem. Seems that being able to combine two pdfs would be useful general function for Hazel.
Thanks.