Sunday, 29 November 2009

"Modifiers" in KRename

Andi Clemens did some amazing work on the batch renamer included and integrated into digiKam. I really like the simple UI and some of the features he included. I think I can get some inspiration from him for KRename (e.g. syntax highlighting).

Lately he posted over the topic of "Modifiers" in the digiKam rename tool, which he added to digiKams renamer and was not able to find in KRename. Modifiers are a way to convert a token, let's say the name of a directory or the artist of a mp3 in some way before inserting it. For example if you insert the name of the directory into the new filename and the directory name is in all uppercase and to match the look of the new filename, you want it to be inserted in lowercase. In digiKam's renamer it is achieved by the token:
[dir.]{lower}

In KRename you would use:
[%dirname.]

So contrary to Andi's post, KRename has modifiers, too. You can add a modifier before any token (after the opening bracket and before the actual name of the token). The modifierst are those used to insert filename's and convert there case. To list the most important ones:





$No conversion, insert the token as it is
%Convert to lowercase
&Convert to uppercase
*Convert every first letter in a word to uppercase
##Format a number with leading zeros


So you can even use modifierst to format numbers for tokens that return number. For example [##tagTrack] will insert the track number of a MP3 formatted with one leading zero if the track number is less than 10.

It is true that KRename does not have a really readable syntax for modifiers here, I think appending {upper} or {lower} like digiKam does it, is a good idea. But there are several other places, too, where the KRename syntax could be improved. I hope that this post will help a few people that also did not know about this feature.

Modifiers in action