Page 1 of 1

Rule to be executed only once an hour on only one file

PostPosted: Sun Jan 06, 2019 2:19 pm
by Robert
I can't get it to work...
I want to create a rule which is executed only once approximately every hour on one file. Then stops and processes the next file one hour after processing the last file and so on.

I thought I could do that with an automator workflow creating a text file within the same folder called something like "temp_import_calibre_hegel.txt" every time the rule is executed and tell Hazel not to process if it finds this file within the folder. Then having another rule to delete the text file after one hour, so that the first rule will be executed again.

Now I can create the "temp_import_calibre_hegel.txt"-file without a problem, but can't tell hazel not to process if she finds the "temp_import_calibre_hegel.txt"-file within the same folder.

I thought that would work with a nested condition: "If none of the following conditions are met for any file or folder in the same folder" ➔ Name is temp_import_calibre_hegel
Image

Image
Where the "Run Automator Workflow" creates the text file "temp_import_calibre_hegel.txt"

But the rule gets executed nonetheless...
I tried several conditions as "Name contains", "Extension is .txt", "Full name" etc. but it does not seem to work.
Does someone has an idea how to solve that? :?:

Thank You for all Ideas!!

Re: Rule to be executed only once an hour on only one file

PostPosted: Sun Jan 06, 2019 3:47 pm
by luomat
Your image didn't show up. It appears to be some sort of Dropbox link, and Dropbox doesn't play well being used as an "embed" link on other sites.

Re: Rule to be executed only once an hour on only one file

PostPosted: Sun Jan 06, 2019 5:14 pm
by Robert
its shown to me.. strange.. I added a second picture. Does that one work?

Re: Rule to be executed only once an hour on only one file

PostPosted: Mon Jan 07, 2019 12:01 pm
by Mr_Noodle
You can try something like "Date last matched not in the last 1 hour" to process something once per hour. That said, I'm unclear when you want the next file processed. If you want it done an hour after the preceding file, you will need more complex logic. Also, note that the order in which files are processed is not something you can rely on.

Re: Rule to be executed only once an hour on only one file

PostPosted: Tue Jan 08, 2019 8:01 am
by Robert
Mr_Noodle wrote:You can try something like "Date last matched not in the last 1 hour" to process something once per hour. That said, I'm unclear when you want the next file processed. If you want it done an hour after the preceding file, you will need more complex logic. Also, note that the order in which files are processed is not something you can rely on.


As I understood it the "Date Last matched is not in the last 1 hour" counts for every file. So If I have 2000 Files in a directory all files are processed, then Hazel waits one hour and processes them again. That is not what I want to achieve. I want Hazel to process one random File out of 20000 files in the directory, then wait a certain amount of time and then process again one random file out of the 1999 files of the directory, then wait again a certain amount of time... and so on.

(I am moving a huge database of PDF files with Hazel (Tagging, OCR, Splitting Pages, Converting if necessary etc.) – and I don't want to mess up so I have to recheck here and then the files moved and added. I don't have the time and nerv to do it all at once, and I need the directory the files go to intact and sorted with ready to use files, as I am continuously work with that directory. So I was thinking 10-15 files a day would be great to sort and add automatically so in the evening I can re-check them and see if everything went as it should...)

Re: Rule to be executed only once an hour on only one file

PostPosted: Tue Jan 08, 2019 11:59 am
by Mr_Noodle
You'll need a script to implement that sort of logic as it's not really something commonly done.

If you are nervous about the results, try it on a copy of the files or keep backups. That way you can verify it all at once without having to wait.

Re: Rule to be executed only once an hour on only one file

PostPosted: Wed Jan 09, 2019 9:56 am
by Robert
Mr_Noodle wrote:You'll need a script to implement that sort of logic as it's not really something commonly done.

If you are nervous about the results, try it on a copy of the files or keep backups. That way you can verify it all at once without having to wait.


Thank you Mr_Noodle! I will see if I can come up with a script and will post it here, if I find a solution. The problem is, that the final step of the process is importing the PDF into calibre and I have not found a way that calibre uses the right Author and Title so here I have to get active and insert the right name manually. And doing this for 2000 files at once is to much right now. But of course I can simply delete that last step in Hazel and do it manually at the end of my working day for 10+ files. I just thought maybe there was an easy solution...

Re: Rule to be executed only once an hour on only one file

PostPosted: Wed Jan 09, 2019 11:29 am
by Mr_Noodle
Not sure if it supports it, but look into using an AppleScript with Calibre.