Hazel rule to "Open a Folder when a file is added"

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

Moderator: Mr_Noodle

Hazel rule to "Open a Folder when a file is added" Sun Jul 22, 2018 12:14 am • by Ward
I have an "on the Web" folder on my Desktop where I collect links (actually .webloc files) to specific web pages. When I drag a URL from my Safari window onto the folder, Safari automatically creates a webloc file with a filename of its choosing (often the page title).

Most of the time, I want to modify or replace Safari's automatic file name. So I've created a Keyboard Maestro keyboard shortcut to open my "on the Web" folder.

To avoid having to press the Keyboard Maestro trigger key each time, I'd like to have Hazel to respond to a new webloc file by (1) opening the "on the Web" folder and (2) selecting the new file. After several failed attempts (including a Hazel rule opening 2000+ webpages in Safari), I'm here asking for advice.

The main problem is finding a Hazel condition that detects the newly created webloc file.

If I can do that, Hazel can "Do the following to the matched file or folder:"

"Show in Finder" + "Bring to front"

-- Ward
Last edited by Ward on Thu Jul 26, 2018 10:31 am, edited 3 times in total.
Ward
 
Posts: 8
Joined: Mon May 21, 2012 11:15 pm

Use "date last matched is after date added" to match newly added files. From there, you should be able to use the "Show in Finder" action.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Use "date last matched is after date added" to match newly added files.

That didn't work for me, but it did encourage me to do more experimenting.

After several failures, I found setting the condition to "Any File" worked for a couple of new files. But then something triggered Hazel into opening my "on the Web" window and start selecting individual files at random, 2 to 3 per second. I was eventually able to use Activity Monitor to force quit the hazelworker process to stop this Finder activity (which was consuming my Mac, including grabbing focus from Activity Monitor).

-- Ward
Ward
 
Posts: 8
Joined: Mon May 21, 2012 11:15 pm

"any file" isn't quite right. I did make a mistake in my earlier post though. It should be "date added is after date last matched". You can also check the sample rules as there is a rule which has a similar function.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:It should be "date added is after date last matched".

"date added is after date last matched" is working, with an annoying side-effect:

When I modify a filename and close the window, it reopens several seconds later because the new filename is triggering Hazel's "date added is after date last matched" condition.

When I initially created my "Open a Folder" rule, I was looking for a Hazel condition that simply detected that a file had been added to the folder, i.e., the folder's file count had changed.
Ward
 
Posts: 8
Joined: Mon May 21, 2012 11:15 pm

If you are renaming it then it may very well appear as a new file. You may want to consider adding a tag to the file after opening and checking for that tag to prevent it from firing again.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:If you are renaming it then it may very well appear as a new file. You may want to consider adding a tag to the file after opening and checking for that tag to prevent it from firing again.

Excellent! That technique blocks reopening the window.
Ward
 
Posts: 8
Joined: Mon May 21, 2012 11:15 pm


Return to Support