Page 1 of 1

Need Help With Rules to Maintain 1 File In A Certain Folder

PostPosted: Sun Sep 21, 2014 8:08 pm
by Mr. Mohon
So I have three folder that I use during different parts of my workflow. They are my "New Scans Folder" "Auto OCR Folder" and "Filing folder"

I use the "New Scans Folder" for the destination for all the new scan.

The "Auto OCR" Folder I want to use to hold one pdf at a time. I want to use hazel to open the 1 pdf in my OCR program that will auto run and then save over the original pdf. Then I want to use hazel again to move the file to the "Filing Folder"

The "Filing Folder" is set with tons of rules for naming and filing documents after OCR.

My Question is that I need help setting up a rule for Hazel that will monitor the "Auto OCR Folder" and maintain one pdf at a time. So that after the OCR is done on the pdf and moved into the "Filing Folder" that hazel moves a new one from "New Scans" to the "Auto OCR Folder".

Is this even possible. I sure hope so. If this doesn't make sense what I am trying to do I can try to explain it again.

Re: Need Help With Rules to Maintain 1 File In A Certain Fol

PostPosted: Mon Sep 22, 2014 12:12 pm
by Mr_Noodle
To do that, the Hazel rule on the New folder needs to check the status of the destination. That will require a script. Is there a reason to have to maintain that restriction? Is it an issue with the OCR program?

Re: Need Help With Rules to Maintain 1 File In A Certain Fol

PostPosted: Mon Sep 22, 2014 10:31 pm
by Mr. Mohon
The restriction is because the OCR program that I am running is only able to do one file at a time. I am using hazel to open the file which triggers the OCR program to run and if there are multiple files then the program doesn't run properly.

Is it hard to write a script that could check the status of the destination?

Re: Need Help With Rules to Maintain 1 File In A Certain Fol

PostPosted: Tue Sep 23, 2014 1:42 pm
by Mr_Noodle
In that case, I don't think you need to limit one file in the folder. What you can do is just have the rules run over each file in the folder and OCR them. If it is feeding them too quickly, you can try adding a pause via a shellscript as follows:
Code: Select all
sleep 60

That will cause a pause for 60 seconds. You can tweak that value as needed.

Not totally foolproof but it is a bit simpler to implement. Doing a script to check the destination is not too bad either but you'll have to learn some scripting to do that.

Re: Need Help With Rules to Maintain 1 File In A Certain Fol

PostPosted: Tue Sep 23, 2014 9:23 pm
by Mr. Mohon
Thank you Mr_Noodle for your help. I am in the initial stages of trying to learn how to write script. I also might have a friend of a friend that could help with a script.

How complicated is a shell script to make?

Re: Need Help With Rules to Maintain 1 File In A Certain Fol

PostPosted: Wed Sep 24, 2014 12:18 pm
by Mr_Noodle
Depends on the shell you are using. By default, it's bash. It's a bit arcane but you can leverage a lot of the programs already on the system. Alternatively, you can use AppleScript which is more accessible.