Drip-feed Files Info Folder (Is this even possible?!)

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

Moderator: Mr_Noodle

Hey fellow Hazelites. I've read through all the documentation but I cant figure out how to move a file to a different folder using the condition "the number of items in the destination folder is 0."

I'm trying to create a mac "robot" that runs macros when instructions are sent to it via email. The instructions are sent as .rtf file attachments. I want to create a drip-feed system for processing .rtf files that are emailed to my mac. I've setup my email to automatically download the attachments into my download folder. I've also set hazel to monitor the download folder for the incoming .rtf file (I have all of this working.)

Here's where I need help:

I want to setup Hazel to move the .rtf file from downloads folder to a folder called Queue. This folder will hold all incoming .rft files that the "robot" needs to process. Then, one by one, I want Hazel to move the "least recent .rtf file" from the Queue folder to another folder called Processing (this folder is monitored by my "robot" and instantly launches a macro using info from the .rtf file) ... BUT, I only want that to happen once the Processing folder has 0 files inside. The reason for this is because I don't want my "robot" to process more than one file at a time. So, the Processing folder is only for storing the file that is currently being processed by my "robot." Once the macro is finished processing, it deletes that file. As soon as the .rtf file is deleted, I want Hazel to move the next "least recent .rtf file" from Queue folder to the Processing folder, thus triggering the macro to restart again with the info from the next .rtf file. I hope this explanation makes sense.


Basically heres my ideal workflow:

1. Incoming email automatically downloads .rtf attachment into downloads folder. (I have this working.)

2. Hazel moves the file into folder called Queue. (I have this working.)

3. Once my "robot" has finished running its current .rtf file, the file is deleted from the Processing folder. (I have this working.)

//THE NEXT STEP IS WHERE I NEED HELP//

4. Once that Processing folder has 0 files inside, I want Hazel to move the "least recent .rtf file" from the Queue folder into the Processing folder. (I can't figure out how to run the rule for Queue folder based on a condition in the Processing folder (0 files in the folder.)

5. New file in Processing folder restarts macro. (I have this working.)

Thanks in advance for any help!

Aaron
squeeze
 
Posts: 2
Joined: Sat Jun 24, 2017 4:53 pm

No way to set conditions based on a destination folder. That said, what is this "robot"? Is it being triggered by Hazel? If so, files in a particular folder are processed sequentially so this type of system may not be needed.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi Mr_Noodle thanks for your quick reply!

The "robot" is actually keyboard maestro. I can set hazel to start a keyboard maestro macro using applescript.. but how do I make sure hazel waits to launch the macro until the current macro is done running? Lets say for example that I send a .rtf file to the "robot" to run a specific task.. and then I send another .rtf file before the current task is finished running.. how do I setup hazel so that the new file doesnt kick off another macro until the current macro has finished running? These macros are using mouse clicks, etc.. so only one macro can run at any time.. Is there a pause until condition that I can use to pause hazel until that macro is done running? Or if you have any other ideas of how this could be done please let me know.. I really appreciate any other suggestions you may have how to get this working. Thank you so much!

Aaron
squeeze
 
Posts: 2
Joined: Sat Jun 24, 2017 4:53 pm

That depends a lot on how Keyboard Maestro processes things. If it reports back to Hazel before it's done, then that would be a problem. One alternative is you could have the macro end by setting a color label. Then you could have Hazel look for that color label before processing the next file.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron