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: 8
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: 11195
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: 8
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: 11195
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: 8
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: 8
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: 11195
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: 8
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: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: triggering rules based on a file Fri Mar 24, 2023 10:24 am • by thersites
Mr_Noodle wrote:If the file already exists in the folder, you can. Otherwise, you will need to be more specific.


The file already exists, but I'd be interested in the specific rule that would check the mod date of the file, because it appears to me that they all apply to the enclosing folder.
thersites
 
Posts: 8
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Mon Mar 27, 2023 10:00 am • by Mr_Noodle
Is the file in a subfolder of the folder being monitored by Hazel? If so, that's an important distinction. Does the download create that folder?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: triggering rules based on a file Mon Mar 27, 2023 10:48 am • by thersites
Mr_Noodle wrote:Is the file in a subfolder of the folder being monitored by Hazel? If so, that's an important distinction. Does the download create that folder?


No, the file is at the top or root level of the folder being monitored by Hazel.
thersites
 
Posts: 8
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Tue Mar 28, 2023 9:50 am • by Mr_Noodle
So not sure what the problem is. You can use the date modified attribute to match the file as needed.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: triggering rules based on a file Tue Mar 28, 2023 9:59 am • by thersites
I thought that applies to the attributes of the enclosing folder. It actually applies to the file?
thersites
 
Posts: 8
Joined: Mon Mar 13, 2023 11:58 am

Re: triggering rules based on a file Wed Mar 29, 2023 9:31 am • by Mr_Noodle
Rules apply to the items in the folder being monitored. Unless you use a nested condition specifying the enclosing folder as the target, nothing applies to the containing folder.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support