Sub-file/folder Count notification strangeness

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

Moderator: Mr_Noodle

Sub-file/folder Count notification strangeness Fri Mar 29, 2013 6:48 am • by kemeny
Hi there, while I'm brand new to Hazel I've had a good look around and haven't found an answer to my problem.

What I'm trying to achieve is fairly simple (I think):
I want to monitor a folder in dropbox that photos will be uploaded to. When the number of photos reaches a certain quantity, say 5, I'd like to receive a push notification on my iPhone that tells me this. I'd like to create multiple similar rules for different quantities.

What I've tried so far:
After unsuccessfully experimenting with 'Number of items' I searched on here to discover that 'Sub-file/folder Count' was a more reliable method, as it ignores invisible files. The following rule pretty much works except from one strange result with the notification that I receive. Hazel sends the notification to Growl, Growl then uses Jedda Wignall's http://jedda.me/projects/pushover-action-growl/ to send the notification to Pushover.

The problem:
For some strange reason I get as many push notifications in Pushover as there are files being counted by Hazel. So, for this example, I get 5 delivered at the same time. 5 notifications is something I can put up with but I'll be asking Hazel to count increasing quantities of photos and I don't want to receive 100s of notifications at a time. Am I missing something quite obvious out? Is there a more elegant solution that anyone can point me to? Any help very gratefully received :)

Image
kemeny
 
Posts: 3
Joined: Fri Mar 29, 2013 6:22 am

You are receiving 5 notifications because you are matching five files. Each of the five files have a parent folder with five files in it.

Move the rule to the parent folder, and run it only against your target (i.e. kind is folder, name is hazel test)
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Thank you so much, a_freyer! Problem solved!
kemeny
 
Posts: 3
Joined: Fri Mar 29, 2013 6:22 am

Also, by the way, thank you for introducing me to Pushover. I hadn't heard of this API, and holy shenanigans is this an awesome service. Purchased the app, running a service on my Raspberry Pi to notify me via my phone of various things. Awesome. Thanks again.

I'm not sure why, in this particular case, you're going through Growl (convenience maybe?), but just for sake of completeness, you can do this:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     …

Do the following to the matched file or folder:
     Run shell script (embedded script)


Embedded:

Code: Select all
curl -s  -F "token=yourapptoken"  -F "user=yourusertoken"  -F "message=5 Photos!"   https://api.pushover.net/1/messages.json
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Very happy to have accidentally given something in return :)

I've actually hooked your instructions up using clockworksms.com now so that my device sends me a text when it counts a specific number of files, I'm going to try and add your more efficient command for Pushover as a fallback. Thanks again!
kemeny
 
Posts: 3
Joined: Fri Mar 29, 2013 6:22 am


Return to Support