"is among the most recent" rule

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

Moderator: Mr_Noodle

"is among the most recent" rule Tue Nov 20, 2012 1:40 am • by nootrop
I have a folder with several type of files - Movie, .nfo files, .jpg files, etc. I'm looking to match the 5 most recent movie files and delete the rest of the movie files. All of the other file should remain and don't need anything done to them. Essentially keep the last 5 movie files and delete the older ones.

I have a rule using "Kind is Movie" and "Date Created is not among the 5 most recent", but it seems that the most recent files are calculated from everything in the folder - not just the 5 most recent movie files?

Can the new "among/not among the most recent" rule be used for a specific type of file or is it limited to everything within the folder? Or am I just missing a sub-level to apply it this way?
nootrop
 
Posts: 2
Joined: Tue Nov 20, 2012 1:29 am

Re: "is among the most recent" rule Tue Nov 20, 2012 12:29 pm • by a_freyer
nootrop wrote:I have a rule using "Kind is Movie" and "Date Created is not among the 5 most recent", but it seems that the most recent files are calculated from everything in the folder - not just the 5 most recent movie files?


As I understand it, this is correct - the "most recent" filters off all files in the folder. A passed shell script is the way to go here.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: "is among the most recent" rule Wed Nov 21, 2012 8:27 pm • by Mr_Noodle
Yes, it picks amongst all the files in the folder. There's not way to pick out of some subset. While I considered it, I need to figure out how to work it into the interface.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: "is among the most recent" rule Sun Nov 25, 2012 1:17 pm • by nootrop
Mr_Noodle wrote:Yes, it picks amongst all the files in the folder. There's not way to pick out of some subset. While I considered it, I need to figure out how to work it into the interface.


Thanks for the confirmation Mr_Noodle!

Just to wrap up the thread for others who find it - I went with a shell script as suggested by a_freyer . It's not the most elegant, but works well enough for now. It's in a Hazel rule, but doesn't need to be. That'll be a placeholder for when Hazel picks up that functionality...

Overall Hazel has done enough to be in my menubar permanently!

Code: Select all
mTot=$(ls -t |egrep '\.mpg|\.avi|\.mkv' | wc -l)
if test $mTot -gt 5
then
 
ls -t |egrep '\.mpg|\.avi|\.mkv'  |tail -n 1 | while read line; do mv "$line" /Users/username/.Trash; done

fi
nootrop
 
Posts: 2
Joined: Tue Nov 20, 2012 1:29 am

Re: "is among the most recent" rule Fri Jun 12, 2015 2:01 pm • by skillet
Thanks for the post, I just spent the past two hours trying to get this very thing to work, not all that intuitive for me. Hazel seemed to be having problems with the viewer, it would show all these files that would be moved but when I ran the rules it didn't move them. Finally after a restart it moved them. I figured I just need to keep tweaking until this works.

In short it seems to be multiple levels of problems with Hazel too bad you can't just pick out a specific file type and keep the most recent. I have an application that generates several different files that I want to to move to another folder none of which the app even looks at except the last created version.

So is there anyway you can at least program in a note that warns us this won't work for known cases like this? The way the rule reads when it says "All" it should work. This really feels like something I was not understanding but is a problem with Hazel.

Perhaps there is another workaround of coloring the most recent file and then moving all the files that aren't that color?
skillet
 
Posts: 31
Joined: Thu Mar 15, 2012 4:11 pm

Re: "is among the most recent" rule Fri Jun 12, 2015 8:27 pm • by Mr_Noodle
Not sure I follow with the color thing. If you can color it, you can also move it.

As for the note, it's a very specific thing and "all" has nothing to do with the misunderstanding here so not sure how that would be suitable.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: "is among the most recent" rule Sat Jun 13, 2015 11:48 am • by skillet
I was thinking maybe I could do a work around by coloring the latest file and then retaining the file with the color I gave it but there seems to be no workaround.

As far as the All goes, it seems confusing if you set it to

All and set the rules
1) is not a folder, and
2) is not among the 1 most recent
3) extension is jpg (my case .bak)
4) Subfolder depth is 0

That it doesn't narrow it down to the latest .bak file. What would the rule be if it did work if not that?
I am probably just not understanding the way the rules work I guess, that's all.

Thanks for the help.
skillet
 
Posts: 31
Joined: Thu Mar 15, 2012 4:11 pm

Re: "is among the most recent" rule Mon Jun 15, 2015 12:25 pm • by Mr_Noodle
The way it works now is "among the 1 most recent" grabs the most recent file altogether. The way you want it, you want it to be somehow dependent on the other conditions. None of the other conditions work like that which is why I need to work out some way to handle that. For now though, the behavior I described is what you have to work with.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: "is among the most recent" rule Mon Jun 15, 2015 5:01 pm • by skillet
Mr_Noodle wrote:The way it works now is "among the 1 most recent" grabs the most recent file altogether.


Okay that makes more sense when I read that. I guess one condition that has two options "Among the 1 most recent _____ FileType rather than have them be two separate conditions. I sincerely hope this can someday be possible, since it would be very helpful for all the clutter I get with the auto backups.

Thanks for the help.
skillet
 
Posts: 31
Joined: Thu Mar 15, 2012 4:11 pm


Return to Support