Notification when downloads folder exceeds a preset size

jmh600cbr

macrumors 6502a
Original poster
Feb 14, 2012
948
2,010
No need for an App, just write a little LaunchDaemon:

Scheduling Timed Jobs
Creating Launch Daemons and Agents
A launchd Tutorial

Just set the thing to check every couple hours, and AppleScript a message to the notification center when appropriate.
ok please help:
I understand that StartCalendarInterval checks based on a time but i cannot find a launchd based on a folder exceeding a certain size. WatchPath keeps and eye on it, but can i set perameters? Thanks
 

Partron22

macrumors 68030
Apr 13, 2011
2,565
756
Yes
Here's a little Applescript that'll check if the download folder is over 5gB, and send a notification with sound if it is:
set z to path to downloads folder
tell application "Finder"
set dlsz to size of folder z
end tell

if dlsz is greater than 5.0E+9 then -- That's 5 gB. Set it for whatever you want
display notification "It's HUGE!" with title "Downloads Folder " subtitle (dlsz as text) & " Bytes" sound name "Sosumi"
end if
return dlsz

You can save this script as an App and have your launchd run it every two hours, or whatever.
 

jmh600cbr

macrumors 6502a
Original poster
Feb 14, 2012
948
2,010
when trying to run this applescript in apple script editor

"Expected “given”, “in”, “of”, expression, “with”, “without”, other parameter name, etc. but found unknown token.

really appreciate your help!

This is what i wrote:

set z to path to "/Users/joshmharris/Downloads"

tell application "Finder"

set dlsz to size of folder z

end tell



if dlsz is greater than 2.0E+9 then -- That's 2 gB. Set it for whatever you want

display notification “Your folder is massive!“ with title "Downloads Folder " subtitle (dlsz as text) & " Bytes" sound name "Sosumi"

end if

return dlsz
 
Last edited:

Partron22

macrumors 68030
Apr 13, 2011
2,565
756
Yes
You're running into trouble with : vs / and trying to assign text as a path/alias.
The standard "path to downloads folder" should work, and "set z to path to downloads folder" will give you an alias that points where you want it to.
 

jmh600cbr

macrumors 6502a
Original poster
Feb 14, 2012
948
2,010
You're running into trouble with : vs / and trying to assign text as a path/alias.
The standard "path to downloads folder" should work, and "set z to path to downloads folder" will give you an alias that points where you want it to.

set z to path to downloads folder

tell application "Finder"

set dlsz to size of folder z

end tell



if dlsz is greater than 2.0E+9 then -- That's 2 gB. Set it for whatever you want

display notification “Your folder is massive!“ with title "Downloads Folder " subtitle (dlsz as text) & " Bytes" sound name "Sosumi"

end if

return dlsz


still gives me the same error and points to the "Your...
 

jmh600cbr

macrumors 6502a
Original poster
Feb 14, 2012
948
2,010
thanks! you were right it was a smart quote issue, i feel dumb but not when i run it, it builds, but the results are "missing value" and no notification nor a sound plays. is it because it isn't finding the downloads folder?

i suspected that may be cause by the folder being empty but i just tested that and it still gives a missing value result
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.