Page 1 of 1

Rename File with Incremented Numbering

PostPosted: Fri Jan 30, 2026 3:44 am
by Japandrewz
I want to create a rule in Hazel 6 that does the following:

If a file name contains “XYZ”, rename the file to XYZ and append a number that increments each time the rule runs. For example, this month, the renamed file would be XYZ 232 and the following month it would be XYZ 233.

I would also like to remove the file type extension.

My rule so far is as follows:

Condition: Name contains XYZ
Action: Rename with pattern

I am not able to find Conditional Attributes to allow for the numbering.

Re: Rename File with Incremented Numbering

PostPosted: Fri Jan 30, 2026 9:48 am
by Mr_Noodle
In the Rename pattern, there's a # attribute you can drag in. That implements an incrementing counter.

If you want to omit the file extension (which may be a bad idea), just don't include that attribute in the Rename pattern.

Re: Rename File with Incremented Numbering

PostPosted: Sat Jan 31, 2026 12:15 am
by Japandrewz
Thank you for the reply. I would like to start the incremented numbering with a value that is not 1. How do I set an initial value under the # attribute?

Re: Rename File with Incremented Numbering

PostPosted: Mon Feb 02, 2026 9:50 am
by Mr_Noodle
Unfortunately, there's no UI for this. Are you comfortable using the commandline? If so, you can try the following:

Code: Select all
cd <the directory where you want the numbering to happen>
defaults write com.noodlesoft.Hazel.DirectoryCounter <the start value>

Replace the stuff between < > with the actual values. For the start value, you'll want to start one less than the first value you want to use (e.g. if you want to start with "5", specify "4" as it will increment before it uses it for the first time).