Actions not waiting for previous action to complete.

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I have a simple rule that runs a shell script and marks the file with a red tag.

I expected that the shell script would need to run successfully before marking the file with the red tag. What I see as I watch the directory with all the files to be processed is that all the files receive the red tag long before the shell script has run.

Why?

I would have a lot more confidence in the process, if the red tag did not get set until after the shell script had successfully completed. Now my only check is to count the files in the source directory vs the destination directory to make sure that match.
alpatti
 
Posts: 12
Joined: Fri Jan 06, 2017 9:00 am

Actions execute in sequence. What does the script do and how are you sure it isn't running? Can you post the script?
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hazel actions are

Run shell script OCRaPDF
Set color label red

script OCRaPDF
#!/bin/bash
open -a "PDF OCR" $1

While monitoring the directory where the PDFs are located, I "Run Rules Now". In a matter of seconds ALL of the files have a red label, but i takes several minutes for ALL of the files to be OCRd.

I expected the actions to executed in sequence, but that is not the behavior I am seeing.
alpatti
 
Posts: 12
Joined: Fri Jan 06, 2017 9:00 am

The "open" command in this case is asynchronous. What that means is that it returns before it completes, which it does in its own thread of execution.

I would recommend instead using AppleScript to interface with the "PDF OCR" program. You may have to put in a wait loop there. If you search the forums here, you can find AppleScripts to drive other OCR programs which you can use as a starting point.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support