Page 1 of 1

Delete backup files based on creation date and files count

PostPosted: Tue Jul 06, 2021 1:42 pm
by YannB
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,

Re: Delete backup files based on creation date and files cou

PostPosted: Thu Jul 08, 2021 10:11 am
by Mr_Noodle
How about doing "Date created is not among the 10 most recent"?

Re: Delete backup files based on creation date and files cou

PostPosted: Thu Jul 08, 2021 2:21 pm
by YannB
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!