triggering rules based on a file

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

Moderator: Mr_Noodle

triggering rules based on a file Mon Mar 13, 2023 2:16 pm • by thersites
I have a shell script that downloads a file that is periodically updated. The file resides in a folder.

What I don't understand is how I can have Hazel re-download the file periodically, because virtually all the conditions for executing rules in Hazel seem to depend on some attribute of the enclosing folder to change. How can I write a rule that, say, will download the file every few hours?
thersites
 
Posts: 5
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Tue Mar 14, 2023 9:34 am • by Mr_Noodle
The file has to already be local for Hazel to process it. You'll need to use something else to trigger that script, like a cron job.
Mr_Noodle
Site Admin
 
Posts: 10614
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: triggering rules based on a file Tue Mar 14, 2023 10:45 am • by thersites
Mr_Noodle wrote:The file has to already be local for Hazel to process it. You'll need to use something else to trigger that script, like a cron job.


It's local. But how can I use Hazel to update it periodically?
thersites
 
Posts: 5
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Thu Mar 16, 2023 9:19 am • by Mr_Noodle
Can you be more specific? What do you mean by updating in this case?
Mr_Noodle
Site Admin
 
Posts: 10614
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: triggering rules based on a file Thu Mar 16, 2023 9:50 am • by thersites
Downloading a new version of the file.
thersites
 
Posts: 5
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Thu Mar 16, 2023 12:06 pm • by thersites
thersites wrote:Downloading a new version of the file.


I'm thinking that Hazel could either 1) re-download the file periodically or 2) check the file's mod date and download the file if it's not within x hours / days etc. I guess I can check the mod date of the enclosing folder, but the script doesn't seem to run properly. My script looks like this:

do curl -o paperpile.bib [URL]; done
thersites
 
Posts: 5
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Fri Mar 17, 2023 9:03 am • by Mr_Noodle
If the file is there already, you can set up a rule to match on mod date. As for the script not running properly, turn on debug mode and check to see if there are any errors in the logs.
Mr_Noodle
Site Admin
 
Posts: 10614
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: triggering rules based on a file Fri Mar 17, 2023 10:55 am • by thersites
Mr_Noodle wrote:If the file is there already, you can set up a rule to match on mod date. As for the script not running properly, turn on debug mode and check to see if there are any errors in the logs.


But I can’t check the mod date of the file itself can I?
thersites
 
Posts: 5
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Mon Mar 20, 2023 10:00 am • by Mr_Noodle
If the file already exists in the folder, you can. Otherwise, you will need to be more specific.
Mr_Noodle
Site Admin
 
Posts: 10614
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support