Delete backup files based on creation date and files count

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

Moderator: Mr_Noodle

I have an app that creates a backup file every time I use the app automatically. The backup folder has 1 level deep subfolders:

`/appBackup/subFolder1`
`/appBackup/subFolder2` etc.

I'm trying to use Hazel to keep the backups inside `subFolder*` to 10 max, and delete the rest (keeping the most recent ones of course).

I got a couple rules on `appBackup/`

1) If Kind is Folder → Run rules on folder content
2) if Date created in not in the last 7 days → move to trash

My problem: if I don't use the app for a few days, Hazel will keep on deleting files based on dates, so I need to first check if the currently evaluated folder has more than 10 files before I delete based on date.

I've tried all sorts of combinations with `Sub-file/folder Count` in both rule 1) and 2) but I can't get a match.

I did try to find a solution in the docs, but I can never find what I'm looking for in there… I must have the wrong mental model about how Hazel work. It's always a struggle to get any rule to behave how I want.

I'd really appreciate any help!

Thanks,
YannB
 
Posts: 6
Joined: Fri Jun 07, 2013 11:21 pm

How about doing "Date created is not among the 10 most recent"?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I would never have guessed "most recent" was an option there… That is definitely not how my brain works :D

That did the trick. Thanks!
YannB
 
Posts: 6
Joined: Fri Jun 07, 2013 11:21 pm


Return to Support