How to: Discover the magic of the sequence identifier

One of the main features in Name Mangler 3 is multi-step renaming. Instead of being limited to just one renaming step, you can add many steps to one renaming task. In prior versions of Name Mangler, you’d need to use Advanced mode, or run multiple repeated single tasks, to handle multi-step renaming tasks. This is a great change for everyone, and has greatly reduced the need to use Advanced mode.

But Name Mangler 3’s Advanced mode still has a few tricks that you can’t do using the “normal” renaming options. One of the most powerful of these hidden gems is the “sequence identifier” parameter for the sequence action. The help file has this to say about the sequence identifier:

The sequence identifier, if included, indicates that sequence indexes are only inferred from the number of files that share the same identifier, as opposed to the overall number of files to be renamed.

Clear as mud, right? That’s entirely my fault, and I’ll try to come up with better wording in a future update. But for now, here’s a hopefully-clearer description:

The sequence identifier, if included, is used to group files together (by a common criteria) for sequencing. All files that share a sequence identifier will be treated as part of the same sequence.

Hopefully that’s a bit clearer…and here’s a real-world example of how you can put sequence identifiers to use to simplify your renaming tasks.

At right is a collection of photos I took of holiday light displays, divided into three separate “setN” folders (one for each house that I shot).

I’d like to rename the photos to indicate that they’re holiday light photos, and use sequence numbers to differentiate them.

For purposes of this example, the desired name would be “Holiday_Lights_nn,” where “nn” is the sequence number. One way to do this is to use a simple two-step action in Name Mangler 3.

The first step will use the Compose action, to completely remove the old name, and replace it with what I want—in this case, I’d use Holiday_Lights_.

The second step will use the Sequence action to add the sequence number to the end of the filename. (It also needs to include a prefix, to attach the name built with the Compose action.)

The completed two-step action would look like this:

While this works, the problem is that the sequence numbers keep increasing, even as the renaming action moves from folder to folder—the first image in the “set2” folder will start at 06, even though it’s the first image in the folder.

While there’s no way to work around this in Name Mangler’s normal modes, the sequence identifier in Advanced mode was designed to handle cases just like this. Starting fresh, set the rename mode to Advanced, and enter this text:

[concatenate

	"Holiday_Lights_"
	[sequence
		from "1"
		increment by "1"
		sleep "0"
		maximum index ""
		minimum number of digits "2"
		identifier <name of parent folder>
	]
	<.extension>

]

With these commands entered in the Advanced section, the preview shows that the sequence numbers will now reset on each change of parent folder. Note that the gray text above is ignored by Advanced mode; any text that’s not part of a command is considered a comment. You can remove the gray text, or replace it with something that makes more sense to you. Here’s how the renamed files look:

If you understand the Advanced mode syntax above, you’re good to go—you can use the sequence identifier in lots of interesting ways, not just for parent folder names.

For example, use unique sequences based on photos’ pixel sizes by using <number of pixels>. Or use <artist> to create sequences by artist in your folder full of audio files.

If, on the other hand, the above Advanced mode commands look like gobbledygook, then keep reading—I’ll attempt to explain what each line does, so you can hopefully take away enough knowledge to put it to your own use.

Here’s how the above script works, line by line…

[concatenate

The concatenate function is used in many Advanced scripts; it doesn’t do anything other than join anything within its confines into a single result. In other words, it’s how the filename is actually assembled from the various bits.

"Holiday_Lights_"

This is simply the static text that makes up the first part of the filename; the trailing underscore is used as a visual separator from the sequence number.

[sequence

This is the start of the sequence numbering function; what follows are the paramaters to that function.

from "1"
increment by "1"
sleep "0"
maximum index ""
minimum number of digits "2"

This section is the guts of the sequence command. It specifies where to start (1), how many to increase by with each step (1), whether to repeat a number before moving on (0 means do not), what the maximum sequence number should be before resetting (unlimited), and the minimum number of digits in the sequence number (2).

identifier <name of parent folder>

This is the line that does the work to change the sequence number when the parent folder changes. You can use any metadata that Name Mangler is aware of, which gives you a ton of choices for resetting the sequence numbering.

In fact, you’re not limited to just metadata. You can put any Name Mangler expression there. So you can group by a find and replace, by a combination of three metadata items, by random numbers, or whatever you like. There’s almost no limit to how you can create your sequence identifiers.

<.extension>

This appends the dot extension to the newly-created filename.

]

This last closing bracket marks the end of the concatenate, and hence, the end of the new filename. Advanced mode may not get as much exercise as it did in older versions of Name Mangler, but having access to the sequence identifier feature is one good reason to put it to use.

One Response to “How to: Discover the magic of the sequence identifier”

  1. Schneb says:

    This worked perfect for me. Here is what I used to identify my files according to the folder, then add a number to it.

    [concatenate
    ,”-”
    [sequence
    from “1”
    increment by “1”
    sleep “0”
    maximum index “”
    minimum number of digits “1”
    identifier
    ]

    ]