File re-name incrementally

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

Moderator: Mr_Noodle

File re-name incrementally Tue Jun 07, 2022 8:03 am • by MeanKidneyDan
So I searched the forums for this, but couldn't find an exact match. This problem seems like something Hazel can handle with aplomb, but I can't seem to get it right.
All the files for which I want this workflow end with an identical pattern: FILE_NAME_ETC_Mvxx where xx is an integer from 1 (NOT 01; there is NEVER a leading zero) to, say 100. I want a workflow that will simply increase that integer by 1, so Mv1 becomes Mv2, Mv9 becomes Mv10, Mv99 becomes Mv100, etc.
My desired workflow will be a folder in which these files will be dropped. Then hazel renames the file by increasing the integer at the end by 1 and moving it to another location.
Is this possible? It sounds like it should be. I can do the pattern matching part, but I can't seem to find that part where it will incrementally increase the file name version when the number already exists. Thanks for any help.
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Tue Jun 07, 2022 10:04 am • by Mr_Noodle
You can use the "counter" attribute (#) to do that. Note that you should use that when the file is in its final folder as the counter is tied to the folder it is in.
Mr_Noodle
Site Admin
 
Posts: 11235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File re-name incrementally Tue Jun 07, 2022 10:12 am • by MeanKidneyDan
Mr_Noodle wrote:You can use the "counter" attribute (#) to do that. Note that you should use that when the file is in its final folder as the counter is tied to the folder it is in.


Thanks for the reply. Ok I think I found the counter attribute. Clearly I'm using it wrong, because upon testing with an "Mv1" file, it became Mv12. Any tips?
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Tue Jun 07, 2022 10:22 am • by Mr_Noodle
Are you tacking the counter onto a file that already has a number? If so, do you want to replace that number?
Mr_Noodle
Site Admin
 
Posts: 11235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File re-name incrementally Tue Jun 07, 2022 10:30 am • by MeanKidneyDan
Mr_Noodle wrote:Are you tacking the counter onto a file that already has a number? If so, do you want to replace that number?


Yes. I want to replace the previous number with the new number that incrementally one more. a +1, if you will.
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Wed Jun 08, 2022 8:38 am • by Mr_Noodle
You'll need to use pattern matching for that. Search the help for more details but you'll want a custom attribute to grab the part of the name you want to keep and use that in the Rename action.
Mr_Noodle
Site Admin
 
Posts: 11235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File re-name incrementally Wed Jun 08, 2022 1:02 pm • by MeanKidneyDan
Mr_Noodle wrote:You'll need to use pattern matching for that. Search the help for more details but you'll want a custom attribute to grab the part of the name you want to keep and use that in the Rename action.


Thanks. I can get it to recognize the name and perform an action, but it doesn't replace the number with the next one, it just adds and new one to it.
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Thu Jun 09, 2022 8:19 am • by Mr_Noodle
Can you post how your rule looks now?
Mr_Noodle
Site Admin
 
Posts: 11235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File re-name incrementally Thu Jun 09, 2022 9:21 am • by MeanKidneyDan
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Fri Jun 10, 2022 8:37 am • by Mr_Noodle
Ok, the issue is that you are not using a custom attribute. You need that to keep the parts of the name you want to keep. The "name" attribute is the whole name, so will, of course, have the previous number. Try using a custom attribute for everything up to that number.
Mr_Noodle
Site Admin
 
Posts: 11235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File re-name incrementally Thu Jun 16, 2022 8:58 am • by MeanKidneyDan
Mr_Noodle wrote:Ok, the issue is that you are not using a custom attribute. You need that to keep the parts of the name you want to keep. The "name" attribute is the whole name, so will, of course, have the previous number. Try using a custom attribute for everything up to that number.

Thanks! Did a custom attribute and now something ever weirder happens.
Here is what I have so far:
General Forumula: https://www.dropbox.com/s/m0kgi2gp8enotlw/Screen%20Shot%202022-06-16%20at%208.52.54%20AM.png?dl=0
Detail 1: https://www.dropbox.com/s/efkvvor8nipzv3r/Screen%20Shot%202022-06-16%20at%208.52.38%20AM.png?dl=0
Detail 2: https://www.dropbox.com/s/rgtnuknimkr5yak/Screen%20Shot%202022-06-16%20at%208.52.26%20AM.png?dl=0

Now what happens is that the current number doesn't increment up, but it gets a NEW number that is seemingly random.
Like, a file name ending in _Mv12 will become _Mv125.
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Fri Jun 17, 2022 8:06 am • by Mr_Noodle
You only want "Match File Name" to include the part you want to keep. The way you have it now, it still has the number from before. You want the part after "Mv" to be outside the custom attribute.
Mr_Noodle
Site Admin
 
Posts: 11235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File re-name incrementally Fri Jun 17, 2022 9:16 am • by MeanKidneyDan
Mr_Noodle wrote:You only want "Match File Name" to include the part you want to keep. The way you have it now, it still has the number from before. You want the part after "Mv" to be outside the custom attribute.


Ok, I've modified it slightly to the custom attribute is just "anything". See here: https://www.dropbox.com/s/djagvv44x7ygc45/Screen%20Shot%202022-06-17%20at%209.07.51%20AM.png?dl=0

and modified the rename. See here:
https://www.dropbox.com/s/yq1q5d1uj4jyk9y/Screen%20Shot%202022-06-17%20at%209.10.35%20AM.png?dl=0

Now what happens is the number changes, but not incrementally necessarily, but doesn't replace it, just tacks it on.
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Sat Jun 18, 2022 8:11 am • by MeanKidneyDan
Mr_Noodle wrote:You only want "Match File Name" to include the part you want to keep. The way you have it now, it still has the number from before. You want the part after "Mv" to be outside the custom attribute.


But how do I tell it what I DON'T want? if every file name is different EXCEPT the _Mv part, wouldn't a custom attribute be the "Anything" attribute?

But since all the file names are variable UNTIL the Mv part, how do I tell it that?
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Re: File re-name incrementally Sat Jun 18, 2022 9:34 am • by MeanKidneyDan
Also, I guess I don't understand the "Anything" attribute, unless it's the "Mv" in my pattern that's making this not match.
But since the name is variable EXCEPT the "_Mv" at the end, I don't know how to get it to recognize any file I might throw at it.

Screenshot 1: https://www.dropbox.com/s/vjjm9wsite47ou6/Screen%20Shot%202022-06-18%20at%209.31.05%20AM.png?dl=0

Screenshot 2: https://www.dropbox.com/s/m0r40u7n4mzpm3u/Screen%20Shot%202022-06-18%20at%209.30.34%20AM.png?dl=0
MeanKidneyDan
 
Posts: 17
Joined: Tue Jun 07, 2022 7:16 am
Location: Massachusetts, United States

Next

Return to Support

cron