Deleting old files from subfolders

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

Moderator: Mr_Noodle

Deleting old files from subfolders Wed Mar 20, 2013 8:03 am • by doodlejones
Dear All,

I'm a Hazel newbie, but am struggling to get it to do what I want to do.

I'd like to use Hazel to keep a folder where I've got some LaTeX projects clean. For those unfamiliar with LaTeX, it is a document processing package that creates documents (usually PDFs), and creates a number of files (at the bare minimum, a single file with the extension .aux, in my case several different extensions). I'd like to delete these files, but only after they are an hour old (i.e. an hour after creation or last modification).

What I would like to achieve is:

In folder "V0.4"
AND all subfolders
DELETE all files that match the criteria
(extension is .acr, .alg, .aux, and so on)

AND
date created modified is not in the last hour.

I've tried to achieve this by:
1. Creating a new rule "Remove all TeX files" which matches any the desired extensions and moves the files to trash (working OK);

2. Creating a new rule "Go in to Subfolders" to go in all subfolders (à la the sticky at the start of the forum); place this rule last;

3. Creating new rule "Not created or modified in the last 1 hour" (If "any" of the following conditions is matched for "the file or folder being matched":

"Date created" "is not in the last" "1" "hour"
"Date Last Modified" "is not in the last" "1" "hour"

I've tried every permutation of order of these files, but Hazel always applies the rule to delete all (appropriate) files indiscriminately, without reference to their created/last modified date.

Any way to manage this?

Thanks,

A
doodlejones
 
Posts: 2
Joined: Wed Mar 20, 2013 7:38 am

Re: Deleting old files from subfolders Wed Mar 20, 2013 8:09 am • by doodlejones
Sorry - figured it out.

Rather than running the rule on files older than 1 hour, I've set it to 'ignore' files less than one hour old.
doodlejones
 
Posts: 2
Joined: Wed Mar 20, 2013 7:38 am

Re: Deleting old files from subfolders Thu Mar 21, 2013 11:55 am • by Mr_Noodle
I think the problem is you are splitting things into two rules with the notion that both get run. Only the first rule to match gets executed. You should add the "1 hour" condition to the first rule where you delete the files.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support