digiKam

Professional Photo Management with the Power of Open Source

Notes about “Modifiers” in the digiKam rename tool

by Andi Clemens

Some users have asked me what modifiers are. They don't seem to know this concept in a renaming tool and are a little bit confused by it.
I will try to explain what the modifiers do and why I implemented the renaming tool in such a way.

image

Update: Error Handling

image

Wrongly placed modifiers are highlighted now, so you can easily see if you made a mistake. A modifier is invalid when it is not added directly behind an option or an option-modifier pair.

Why Modifiers?

As mentioned in an earlier article, renaming in digiKam was not quite powerful, so I started to implement this new widget. I didn't want to have a full-blown
dialog for this, because it should be embedded in many places like in the MainUI, the importer and the BatchQueueManager. The concept of entering a template
string for renaming should already be known to users from tools such as KRename and similar batch renaming applications.

I tested some batch renamer tools and most of them seem to allow modifications only for the original filename, but not for all the other options they provide for renaming.
I never understood this limitation. What if I add the directory name and it is all uppercase, but I want it to be lowercase, to match the look of the overall new filename?
There doesn't seem to be a way to do this.
I know Metamorphose2 seems to do have something like modifiers, too, but for me the GUI is way too complex.
Edit: KRename seems to have modifier for all their options, too.

So I started my own tool and added keywords, that can be applied to every renaming option currently available. I'm going to explain the modifiers a little bit in the next section,
to show how they can be used.

Examples

Case Modifiers

Case modifiers change the case of a renaming option. Currently there are three modifiers available: Lower, Upper and FirstLetterUpper.
In the future these modifiers might be controllable with range parameters, so that you can, for example, have the first three characters of a renaming option in uppercase and leave the rest as is.

Lower

This modifier allows to convert a renaming option to lowercase characters.

image

Upper

This modifier allows to convert a renaming option to uppercase characters.

FirstUpper

This modifier allows to convert each word in a renaming option to start with an uppercase character.

image

Others

Trimmed

This modifier removes leading, trailing and extra whitespace from a renaming option. As you can see in the example screenshot, I added some whitespace to the replace modifier, that is removed again by the TrimmedModifier.

image

Unique

This modifier makes renaming options unique, avoiding name collisions. For example if you use the pattern shown in the screenshot, it is likely to have duplicate names.
The rename tool wouldn't let you process these files and mark colliding names in red. The UniqueModifier can help to avoid this. As you can see in the example, it adds a suffix number
to each [date:hhmmss] parse result when the value has already been used before.

image

Default

The DefaultModifier can be used to set some value for options that don't return a string for some specific images. This can most likely happen with the camera or metadata renaming option.
To avoid a gap in the filename, you can set a default value, that is inserted in this case.
See the following screenshot:

image

Let's assume that some of these images where scanned in, so they have no camera name. We set the default value to "Scanner" in this case, and fill in the gaps.

Replace

This modifier replaces text in a renaming option, you can use regular expressions for more advanced pattern matching.

image

Range

This modifier only displays a given range of a renaming option.

image

Plans for the future

As you have seen in the screenshots, modifiers can be chained together. In the future I plan to add grouping, so that you can enclose renaming options and apply modifiers on each of them in one go, for example:

[group][cam]_####_[file][/group]{upper}

or similar. I'm not yet sure how to do it, but this could be one way.