Using the Counter Attribute

When editing a pattern for the “Rename” action, the counter   attribute becomes available.

This attribute represents a number that increases by one each time the action runs. You can use this in a renaming action to number files.

In the pattern above, the counter follows the filename and a hyphen, and comes before the extension. So, if your rule repeatedly encounters and matches new files named  somefile.doc , this action creates files named  somefile-1.doc somefile-2.doc , and so on. But it works the same way even when filenames differ. For example, suppose your condition matches files whose names begin with Z, and you drag the files  Zing.txt Zip.doc , and  Zoom.xls  into the monitored folder. A “Rename” action with the pattern above would name them  Zing-1.txt Zip-2.doc , and  Zoom-3.xls , respectively.

Note:  Each folder has its own counter.

Customizing Counters

You can customize the numbers (or letters) used in a counter in several ways.

First, if you click the tiny arrow in the counter   token, a pop-up menu appears with numerous options.

Your options on this menu include the minimum number of digits, “Edit Number Format,” “Adjust Number,” and “Replace text” (as is true for any number-based attribute; see  Using Patterns in Actions ), plus:

  • “Always increment”/“Use lowest available”:  By default (using the “Always increment” setting), the counter always increases; it never backtracks or fills in holes in the sequence. But if you remove filename-1 and filename-2 from your monitored folder while leaving filename-3 there, you can instead choose “Use lowest available” to force Hazel to choose the lowest number that’s not already in use by a file in the monitored folder.

  • “1, 2, 3…”/“a, b, c…”:  Choose “1, 2, 3…” (the default) to use numbers, or “a, b, c…” for letters.

When you’re finished customizing your counter, click “Done.”


Using Patterns in Actions

Editing Date Patterns