Opening mounted Volumes in Finder

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Opening mounted Volumes in Finder Wed Jan 26, 2022 1:25 pm • by matt!
I'd like to automatically open mounted Volumes in a Finder window. This is so connected devices like a camera or game console and storage like SD cards are more visible after I attach them.

Folder: /Volumes
Rule: Open Mounted Volume
- Do the following > Open > with application: Finder

This works, but it also displays volumes mounted by the system, such as my backup drive, Recovery partition, etc.

So I decided to add a shell script to exclude specific volumes:

Folder: /Volumes
Rule: Open Mounted Volume
- Passes shell script > embedded shell script
- Do the following > Open > with application: Finder

Code: Select all
return $(( $(diskutil info "/Volumes/$1" | grep -e "Volume Name:\s*320GB" -e "Volume Name:\s*Tardis" -e "Volume Name:\s*External" | wc -l) ))


This script returns 1 for volumes to exclude, and 0 for volumes to match/pass. It counts matching lines using grep on diskutil info output.

This kind of works, but it's not satisfactory mostly due to the awkward way I need to exclude volumes.

Any suggestions how I can do this in a better way?

I'm using Hazel 4.4.5
matt!
 
Posts: 14
Joined: Thu Jun 19, 2008 7:41 am
Location: Cornwall, UK

Re: Opening mounted Volumes in Finder Wed Jan 26, 2022 2:02 pm • by matt!
Doh! Keep it simple.

The shell script is only needed to give the drive time to mount fully.

Let's see how that goes for a while.

Image

And maybe this thread is in the wrong sub-forum.
matt!
 
Posts: 14
Joined: Thu Jun 19, 2008 7:41 am
Location: Cornwall, UK


Return to Open Discussion