Delete old files as drive gets full.

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

Moderator: Mr_Noodle

Delete old files as drive gets full. Fri Oct 04, 2019 11:26 pm • by thesillyrabbit
Setting up home security camera. I'm already using Hazel to sort motion clips onto a external usb drive by date.

Is there a way when the drive gets full (like less than 20 gigs) that I can setup Hazel to start deleting files by age? So it just keeps deleting the oldest files first.

Thanks
thesillyrabbit
 
Posts: 2
Joined: Wed Aug 17, 2016 1:56 am

Re: Delete old files as drive gets full. Sat Oct 05, 2019 5:27 am • by Dave61
Image
Dave61
 
Posts: 94
Joined: Tue Jul 10, 2012 4:56 pm

Re: Delete old files as drive gets full. Mon Oct 07, 2019 11:14 am • by Mr_Noodle
@dave61 Thanks for posting that rule. I'd add another condition to tell it when to stop as right now, it may end up deleting everything as there's always 1 least recent file.

@thesillyrabbit Not sure how well versed you are with scripting, but you'll probably have to use a script to determine disk usage. You can then have Hazel use that in a condition.
Mr_Noodle
Site Admin
 
Posts: 8197
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Delete old files as drive gets full. Sun Oct 20, 2019 7:58 pm • by durosity
Somewhat related to this topic I also want to do something similar to this, but in this case there's some subfolders and multiple cameras. A volume structure example is:

/Volumes/Extras/SecuritySpy/Front Door/2019-10-20/ then the video files made that day for that camera would be stored in there, and same for Back Door, etc. Now what I want it to do is delete the folders for anything over 3 days ago.. I can kinda do this by listing each individual folder separately in Hazel but I'd rather have it tidier and work by way of just running the rules on the SecuritySpy folder and it run the process on any subfolder that meets the criteria (Because there's 14 cameras and possibly more to come in the future). I tried setting my system up like a KBA I found had for sub folders but it didn't seem to work.. it just wanted to delete the oldest folders directly in the SecuritySpy folder.

Any ideas?
durosity
 
Posts: 2
Joined: Sun Oct 13, 2019 5:54 pm

Re: Delete old files as drive gets full. Thu Oct 24, 2019 7:53 am • by Dave61
My thoughts, set up rules in "SecuritySpy" folder:

1) If
• kind is folder AND
• date last modified is not in last three days
then
• move folder to trash

2) If
• kind is folder
then
• run rules on subfolder

Note the sequence, you need the rules that might act on subfolder itself before running the rules on content.

If you have other rules in SecuritySpy then you may need to add additional conditions (e.g. subfolder depth or path includes) to ensure only desired folders are deleted.
Dave61
 
Posts: 94
Joined: Tue Jul 10, 2012 4:56 pm

Re: Delete old files as drive gets full. Fri Nov 08, 2019 5:06 pm • by durosity
I'll try it out and see how it goes.. thanks!
durosity
 
Posts: 2
Joined: Sun Oct 13, 2019 5:54 pm


Return to Support