Renming with Lowest Number Available.

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

Moderator: Mr_Noodle

Renming with Lowest Number Available. Fri Jul 24, 2020 4:24 pm • by optimus1509
Hi,

I am trying to auto sequence a set of folders as per below -

01. untitled folder
02. untitled folder
03. untitled folder
04. untitled folder

My rule is configured as below -

kind is folder

rename with pattern #(use lowest available, 00). Name(no changes) extension(no changes)

the rules works correctly for some iterations and then suddenly all previously renamed folders will change to the following -

01. 01. untitled folder
01. 02. untitled folder
01. 03. untitled folder
04. untitled folder

Any idea what is wrong here? My requirement is to simply rename the folders by adding a sequence in '00' format. If there are 4 folders and i delete the 1st folder, the next folder i create should be renamed with 01. and not 05. This should not be renaming all other folders. Please advise.
optimus1509
 
Posts: 7
Joined: Thu May 05, 2016 1:47 pm

Re: Renming with Lowest Number Available. Sun Jul 26, 2020 11:13 am • by Elleo
It sounds like your rename rule is running in a loop. Try adding color tags to the rules.
Rule 1 - add a red color label when the folder is first added continue matching (you can use date added is after date last matched rule)
Rule 2- all folders with red labels get renamed (with your rules for renaming ie. lowest number) continue matching
Rule 3- tag folders with a yellow label after it has had the rename rule processed
Just FYI- the lowest number rule will rename the folder from the lowest available number - so I think it might make your folder number 04 not 00. I'm not sure if it can fill in missing numbers. If you want everything to be perfectly sequential then I think you will need the incremental rule which will rename all the folders when you readd a new one
Elleo
 
Posts: 9
Joined: Thu Jun 25, 2020 3:28 pm

Re: Renming with Lowest Number Available. Sat Aug 08, 2020 3:30 pm • by optimus1509
Elleo wrote:It sounds like your rename rule is running in a loop. Try adding color tags to the rules.
Rule 1 - add a red color label when the folder is first added continue matching (you can use date added is after date last matched rule)
Rule 2- all folders with red labels get renamed (with your rules for renaming ie. lowest number) continue matching
Rule 3- tag folders with a yellow label after it has had the rename rule processed
Just FYI- the lowest number rule will rename the folder from the lowest available number - so I think it might make your folder number 04 not 00. I'm not sure if it can fill in missing numbers. If you want everything to be perfectly sequential then I think you will need the incremental rule which will rename all the folders when you readd a new one


I have tried this and it does not seem to work. I think the feature may be broken. Even if i select No change to the name any new folder add with a new name will start from 01. This is not the intended use for the feature.

However, the only scenario I have seen it to work is if the folders have the same names initially for Hazel to rename them and eventually make then unique For Ex. If you keep adding 'untitled folder' hazel will rename them to make them unique. The moment you add a folder with a different name it will start back at 01. Anyway to circumvent this?
optimus1509
 
Posts: 7
Joined: Thu May 05, 2016 1:47 pm

Re: Renming with Lowest Number Available. Mon Aug 10, 2020 10:02 am • by Mr_Noodle
Not if you set it to use the lowest available number since Hazel can't really know which files were numbered specifically and which ones happen to have a number.
Mr_Noodle
Site Admin
 
Posts: 11247
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Renming with Lowest Number Available. Tue Aug 11, 2020 6:18 pm • by Elleo
I've tested and this is how it works.
From your example I thought your folders had the same name. So, for instance, I'm adding a folder called "James pics"

I set my rename rule to "name" & # (set to lowest available)
My folders become:
James pics_01
James pics_02
James pics_03

Later if I delete James pics _02
the next time I add "James pics" it will become
James pics_02

However, if I set my rename rule to "name" & # (set to incremental)
My folders will still be:
James pics_01
James pics_02
James pics_03

But later if I delete James pics _02
"James pics" becomes James pics_04

I have a feeling neither of these scenarios are what you are looking for. It sounds like you may be looking to append a counter to each folder as it is added which is not the same thing & would probably need a script.
A few bugs or hiccups that I have noticed with renaming. Hazel can run too fast sometimes. I set the color tags as mentioned in my previous post to make sure the Rule doesn't loop. I also sometimes add a delay via an Applescript after the rename. This is usually just 1 or 2 seconds to make sure that the color label gets added. If the Rule re-runs by accident then the name will be tagged with another_01 onto the end. (Which is what your example seemed to suggest was happening)
Lastly, Hazel seems to have a "memory" when using the # in incremental mode. This can make numbers not incremental If you end up testing and deleting things. Hope this helps.
(Also I think in my last post I accidentally switched the way incremental & lowest number work- what I explained here is correct- just tested & it worked as described)
Elleo
 
Posts: 9
Joined: Thu Jun 25, 2020 3:28 pm


Return to Support

cron