KRename

The free batch renamer

A short Introduction into KRename

Copyright © 2004 Dominik Seichter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts.

Table of Contents:

1) Introduction	4

1.1) What is KRename?	4

1.2) How much does it cost?	4

1.3) Where can I get it?	4

1.4) I need help, whom can I ask?	4

2) Using KRename	5

2.1) The First Start	5

2.2) Adding Files	5

2.3) Rename, Copy or Move?	6

2.4) Plugins	6

2.5) Building the filename	6

2.5.1) Building the filename – Beginners Mode	7

2.5.2) Building the filename – Advanced Mode	8

2.6) Renaming Completed	11

3) Examples	12

3.1) Sorting your picture collection – Beginners Mode	12

3.2) Capitalizing some files – Beginners Mode	12

3.3) Converting filenames to lower case – Advanced Mode	13

3.4) Renaming your mp3 collection – Advanced Mode	13

4) Support us!	14

5) Thanks to:	14

1) Introduction

1.1) What is KRename?

KRename is a batch renamer or a mass renamer, how it is called by a few people, for KDE. A batch renamer takes a list of files and renames them using a given set of expressions. KRename has lot's of features which make the renaming easier. First of all there is the powerful GUI with two GUI modes: One mode (called wizard-mode) is for first time KRename users witch only want to do simple tasks and the other mode (called tabbed-mode) shows the full power of KRename and allows you to do almost anything with your filenames. But there is much more than only the GUI. KRename supports all of the great KDE technologies, like KIO-Slaves, which allow to rename files almost everywhere (on ftp:// servers, over fish:// or on smb:// shares), DCOP, giving you easy scripting access to KRename, and the powerful KDE file plugins. Thanks to the file plugins KDE can access information, such as the interpret of a mp3 or ogg file. And of course there is support for simple stuff like converting a filename from upper case to lower case, adding to a number to a filename or doing simple find and replace on filenames.

1.2) How much does it cost?

KRename is free software licensed under the GNU GPL license.

1.3) Where can I get it?

The best way to obtain KRename is via the internet. Take a look on our webpage at http://www. krename.net to download KRename in source or binary form. Our webpage also offers a screenshot gallery, a complete feature list and a support forum, where you can post your questions.

1.4) I need help, whom can I ask?

We offer different ways of support. Please choose one of them to get in touch with us:

For support reasons we are offering a Mailing List. So, if you are using KRename a lot, we would strongly recommend joining the mailing list. To join the list, please visit: http://lists.sourceforge.net/lists/listinfo/krename-users and add your email address. After that you will get a confirmation mail, which you simply reply to. Once you have done that, you are member of the KRename Mailing list. (fairly low traffic). Send all messages to krename-users@lists.sourceforge.net these will be sent to all list members. We will try to answer you as soon as possible (normally within the next 8 hours). For regular users or if you want better information and contact, please join the Mailing list of krename. The traffic is quite low, between 2 mails a week and 20 mails a day. We strongly recommend this for all frequent users of krename!

If you don't want to join the mailing list, you can use the same address to send us mails: Please use krename-users@lists.sourceforge.net for all kind's of enquires and to give us feedback.

We also provide a forum, where you can ask questions or discuss with us and other users. Please visit http://www.kbarcode.net/forum

We also have an IRC support channel. So, if you are familiar with IRC, please connect to the Server irc.freenode.net and join the #kbarcode channel to get support for KRename.

2) Using KRename

2.1) The First Start

This dialog will pop up after you start your freshly installed KRename for the first time. This is the only question you will be asked on the first startup. You have to decide wether to use the GUI mode for beginners or the advanced mode, which has lot's of options and is therefore very powerful.

You can still change the GUI mode later in the preferences (click on the Settings menu item, then Configure KRename... and switch to the other mode in Look and Feel).

This manual will provide a introduction into both modes.

2.2) Adding Files

Regardless of whether you are in beginners or advanced users mode, you'll see this page. On this page you have to perform the first step: Add the files you want to rename.

You can either drag and drop them from a Konqueror window into KRename or by just pressing the Add... button. In the following dialog. You can select files just like you can in every other KDE application, too.

Another way to add files to KRename is to select a bunch of files in Konqueror and select from the context menu Actions -> Rename with KRename.

You will notice some new options on the bottom of the dialog box though. These are interesting when you have selected one (or more) directories by dragging a frame with your mouse around the directory icons in the dialog. If you select the Add sub directories recursively option, all the contents of directories in the selected directory will be added, too. If Add directory names only is selected, only the directories itself are added to the list and not their contents. This option is interesting if you want to rename your directory structure.

This page also offers a nice preview and the ability to sort the files either ascending or descending. Additionally you can sort the files by hand. Change the Sorting to Unsorted and use the up and down arrows to move selected files up or down in the dialog.

2.3) Rename, Copy or Move?

The second step (as well in beginners and advanced mode) is to choose whether your files should be just renamed, renamed and moved to a new directory or copied and renamed to a new directory. The last option is the safest option as you just modify the names of the copied files. If something went wrong you can just delete the copied files and try again with the originals.

By default KRename will never overwrite existing files. Only if the option on this page is checked existing files will be overwritten.

The last option you have on this page is the option to create an undo script. An undo script is a normal bash script that will undo the renaming operation. You can either execute the script from your commandline (you have to pass the --krename option so that the script works) or by using KRename's confortable GUI for this task: Extras -> Undo old renaming operation... . Be careful with this option as it cannot be used to undo renaming of remote files. The instant undo, which is always active, is able to undo remote file renaming!

2.4) Plugins

If you are using the beginners mode you can jump straight to the next chapter as this information is only important for the advanced mode. The plugin page is ommitted in the beginners mode, as it adds some complexity and is not necessary for most tasks. Even if the plugin page is missing in beginners mode, plugins like the mp3 plugin do work in beginnres mode!

The plugin page in the advanced mode lists all plugins available to KRename. Most of them will be KDE file plugins. For KDE fileplugins, KRename shows just the tokens (i.e. KRename commands) they provide. There are a few other plugins which are part of KRename. These plugins allow the changing of the permissions of the files during renaming or their modification dates and times etc. These plugins are easy to use as they work in the same way as the corresponding Konqueror dialogs.

2.5) Building the filename

The last step is to decide on the new filename for your files. This step is different between advanced mode and beginners mode. For this reason both modes are described separately.

2.5.1) Building the filename – Beginners Mode

The screenshot above shows the beginners mode of KRename. The dialog is split into two parts. In the top part you can build and setup the filename and in the bottom part you have a real time preview showing immediately what results you would get when pressing Finish.

You can add a prefix and a suffix to every filename. This can either be a fixed text, which is added in the right most field, a number or the current date. You can choose to add a number or date in the drop down list right to the text label saying „Prefix:“ or „Suffix:“. If you decided to add a number you can set in the right part of the dialog with which number the counter shall start and how many digits the number shall have. If the number of digits is 2, your numbers will be formated like this: 01, 02, 03, ... 09, 10, 11 ... 100. A value of 4 will result in 0001, 0002 etc. .

The important part is now the filename itself. Take a look on the drop down list besides the „Previous Name:“ label. It has options to leave the filename as it is (and just add the prefix/suffix), to convert it to lower case or upper case, to capitalize it or to use a custom filename (which may also be no filename at all). In all cases the prefix and suffix will be added.

In the beginners mode you can also use the KRename commands (tokens) which are used in the advanced mode to create a new filename. Using these tokens you can add the interpret of a mp3 file to the filename. Just enter [mp3artist] into the custom filename field. These tokens are more closely explained in the following part on the advanced mode.

2.5.2) Building the filename – Advanced Mode

In the advanced mode you can completely create the new filename by entering an expression in the Template text field. The text is constructed by plaintext and by certain tokens. Tokens are KRename commands or keywords with a special meaning. All commands are listed in the dialog which pops up when pressing the Functions... button.

Of course you will see that the real time preview below is updated immediately as soon as you change the template string.

Contrary to the beginners mode, you can also change the extension of the file in the advanced mode. By default KRename will use the extension of the input file, but if you click on the Use extension of the input file check box you can build the file extension in the same way by using tokens as in the normal filename. You might also want to specify from which point the file extension should start. This is useful if you are working with filenames like mybackup.tar.bz2 or backup01.05.2004.zip. In the first case you want the extension to start on the first dot (i.e tar.bz2 is the extension) and in the latter case the extension should start on the last dot so that zip is used as file extension.

So how is the template built up? It is quite easy: Just add a textstring and a few tokens, e.g.: „wallpaper ##“ will result in filenames: „wallpaper 01“, „wallpaper 02“ ... . „wallpaper“ is not a known KRename token, so KRename will leave it as it is. But the „#“ stands for a number in KRename so it will be processed and replaced by a number. The more #'s you add after each other, the more leading 0 you will get (see number of digits in beginners mode).

What tokens are available? The table on the next page will give you hopefully some answers:

Token	Description	Example Template	Input filename	Resulting filename
$	Insert the old filename unmodified	$	Ali_Larter.jpg	Ali_Larter.jpg
%	Insert the old filename converted to lower case	%	Ali_Larter.jpg	ali_larter.jpg
&	Insert the old filename converted to upper case	&	Ali_Larter.jpg	ALI_LARTER.jpg
*	Insert the old filename capitalized	*	beethoven's symphony.mp3	Beethoven's Symphony.mp3
[x]	Insert the character on position x of the old filename in the new one	[2] file.txt	d4datafile.txt	4 file.txt
[x;y]	Insert y characters of the old filename, starting at position x to the new filename	[3;12]	06Country Roads.mp3	Country Roads.mp3
[x-y]	Insert all characters of the old filename from position x to position y in to the new filename	[7-16]	summer holiday 1.jpg	holiday 1.jpg
\	Inserts the old filename with leading or trailing whitespaces stripped	\	file .dat	file.dat
#	Insert a number into the new filename	$ ##	picture.png	picture 01.png
#{0;1}	Insert a number which has a custom start value 0 and a custom stepping 1. This allows one two use different counters in one filename.	## $ ##{04;1}	file.dat	01 file 04.dat
[length]	Inserts the length of the original filename into the new one. The interesting thing is that you can substract numbers from this token: [length-2] and use it in tokens like [x-y]	[7-[length]]	summer holiday 1.jpg	holiday 1.jpg
[dirname]	Inserts the name of the base directory into the new filename	[dirname]_$	Ali_Larter.jpg	pictures_Ali_ Larter.jpg
[dirname.]	Inserts the name of the base directories base directory (the more dots you add, the more KRename will go up in the directory tree)	[dirname.]_%	Ali_Larter.jpg	home_ali_larter.jpg
/	Creates a new directory with the name being left to the / and the filename being right	Pictures/## $	Ali_Larter.jpg	Pictures/01 Ali_Larter.jpg (Pictures is now a directory)

These are the basic and most important tokens of KRename. One special thing to mention about all tokens which are enclosed in brackets [ ] is that you can format them like the filename itself. E.g.: the & operator which turns the old filename to upper case, converts the string returned by the keyword in brackets to upper case, too. For example the template „[&1][%2-]“ creates a new filename with the first letter of the filename being upper case and all the others being lower case. Formating numbers works also, if the second character in a filename is a number like „3“ and you use the command [##2] you will get as result the formated character at position 2: „03“.

Additionally to the main tokens, KRename has tokens which are useful to insert the current date or similar stuff into the new filename. These are listed in the next table. I did not add an example this time as they are really easy to understand and you can simply try them out thanks to Krename's real time preview.

Token	Description
[accessdate]	the last access to the file happened at this date
[creationdate]	the file was created at this date
[modificationdate]	the file was for the last time modified at this date
[user]	the owner of the file
[group]	the group of the file
[date]	the current date
[time]	the current time
[day]	the current day
[month]	the current month
[year]	the current year
[second]	the current seconds
[minute]	the current minutes
[hour]	the current hours

Well that's still not all. All the KDE file plugins have their own tokens, too. I won't list them all here, because there are simply far too many and depend on the plugins you have installed on your system. Just take a look on the list of tokens that appears when you press the Functions... button. All tokens of file plugins are built up using the same scheme. At first there is a prefix (usually the file extension of the corresponding file type) and then there is the name of the token. E.g.: [mp3artist], [mp3title] or [jpegCreationDate].

After you have created the template string you might want to do some find and replace operations. For example you could replace all spaces by underscores. The Find and Replace button is responsible for this task and is pretty straight forward. You can even use regular expressions for find and replace. The regular expressions can easily be built using KDE's graphical regular expressions editor.

Additionally you can configure the behaviour of the counter when you press the Numbering... button. The start value can be configured as well as the stepping value (both can also be negative values). Most of the time the defaults will be sufficient. Before you can use this dialog, you have to add at least one # to the template, otherwise the button to open the dialog will be disabled.

The last dialog to mention is the Insert part of filename... dialog which is launched using the button with the same name. Creating tokens like [1;6] usually involves lot's of nasty counting of letters and characters to find the correct position. Using this dialog you can just select the region you would like to have inserted as a substring with your mouse and it will be inserted into your template. You can even invert the selection so that everything but the selected text is added to the new fileame.

Now you should be able to create a template and rename files in the advanced mode of KRename. It's time to press Finish now and let the renaming beginn.

2.6) Renaming Completed

After renaming has completed you will see a dialog like the one below (hopefully without the error messages). The dialog shows which errors did occur (if any did occur) and how many files were renamed succesfully. In this case I got some errors because the files I tried to rename would overwrite other files and KRename does not overwrite existing files by default. You could instantly undo the operation by pressing Undo. This even works for remote files, contrary to the undo shell script. But as soon as you close this dialog, KRename will quit and the option to undo without using a script will be lost. Rename More... allows you to rename either all files again our just the processed or unprocessed one. You can also start a fresh instance of KRename. Open Destination... opens the destination directory in Konqueror so that you can see the results in the filemanager.

3) Examples

This chapter contains some examples for specific use cases of KRename, like the renaming of freshly, legally, downloaded mp3 files or the renaming of your photo collection. You can try these examples at home and they will help you to better understand KRename. The headline of every block says whether the example is for beginners or advanced mode or for both. The description is only for the building of the filename for the new files. I think adding the files correctly to KRename is easy enough so that it does not have to be described here again.

3.1) Sorting your picture collection – Beginners Mode

If you copy the images from your digital camera they have often ugly names like DFH0034.jpg. Maybe you want to give them a better name with KRename. If we want the files to be named „NUMBER holiday CURRENTDATE.jpg“ where number and current date get replaced. The screenshot shows how we have to set the different options. First we have to add the number at the beginning. Therefore we are setting prefix to „Number“. Afterwards we are going to append todays date with setting suffix to „Date“. Now we have to switch previous name to „Custom Name“ and enter „ holiday “ text field. You might also want to increase number of digits to get „01“ instead of plain „1“ which looks better if you have more than 10 images. In advanced mode you would use „## holiday [date]“ as template to achive the same

3.2) Capitalizing some files – Beginners Mode

Easy one: Just set previous name to „Capitalize“ and the job is done. But what if you want to strip the first two characters from filename at the same time? You have to set previous name to „Custom name“ and use the tokens one would use in advanced mode. In this case you would use [*2-[length]] to strip the first two characters and capitalize the rest.

3.3) Converting filenames to lower case – Advanced Mode

You got lot's of files from a Windows system and all filenames are in upper case? Those filenames are just ugly aren't they? Well, this is an easy task for KRename. Just set the template for the filename to %. That's not all though. If you take a look at the real time preview, you will see that the file extension is still in upper case. But we can solve this problem, too. Uncheck the checkbox Use file extension of the input file and enter also a % in the now enabled template field for the extension. And that is all. Press Finish now.

3.4) Renaming your mp3 collection – Advanced Mode

We want all our mp3 (or ogg) files to have names formated like this NUMBER INTERPRET – TITLE and every album should get its own directory named INTERPRET – ALBUM. We assume that all your files are tagged properly. The template we use is quite simple, because the MP3-Info plugin provided everything we need.

If the mp3 plugin is missing on your system, you have to installed the KDE multimedia package. Some distributions (especially RedHat) removed mp3 support completely from their distributions so you will have to compile KDE multimedia from source or get binary packages from some other source.

The template looks like this: „[*mp3Artist] - [*mp3Album]/[##mp3Tracknumber] [*mp3Artist] - [*mp3Title]“. To ensure that everything is capitalized correctly, I added a * in front of all tokens representing a text value. In front of [mp3Tracknumber] I added two #'s so that numbers are formated like „02“. The / creates a directory for every new artist and album. So we have two parts here, the first in front of the slash is only responsible to create the new directory and place the files in it. The part behind the slash is the filename to which the files get renamed.

3.5) Replacing spaces with underscores – Advanced Mode

The template for this operation is very easy. We use just the old filename, therefore the template is $. Now we need Krename's find and replace function. Open the find and replace dialog and add in the find field a single space and in the replace with field an underscore (_). Now press Add and OK. In the preview you should now see all spaces in your filenames replaced by underscores.

4) Support us!

KRename is an open source project completely created by volunteers. For this reason we can always use your help. This does not mean that you should be Linux wizard or computer expert. You can help us with:

Reporting bugs you found

Sending in your feature requests to improve KRename

Giving feedback on how you used or how you are using KRename

Writing new or improving existing documentation

Translating KRename in your native language and therefore making it easier to use for people who are not that good in English

Creating RPM files for your distribution so that KRename is easier to install (most people do not like to compile source codes)

Advertise KRename to your friends (or Open Source in general)

You can also donate some money to the PayPal Account of Dominik (the programmer) if you are satified with Krename

5) Thanks to:

KRename is realised and creatd by:

Programer: Dominik Seichter <domseichter@web.de>

Project Manager: Stefan Onken <stonki@stonki.de>

Thanks goes also to all the Translators and Packagers and to everyone who has contributed to KRename. In no particular order:

Renè Gass, Steven P. Ulrick, Jose Rodriguez, Michael v. Ostheim, Nicolas Benoit, Arpad Biro, Mark Volkert, Daniele Medri, Michael Zugaro, UTUMI Hirosi, Trevor Semeniuk, Groult Richard, Michael Elvers, Andreas Pour, Per Ovind Karlsen, Elrondo, Ilya Ivkov, Gaffer

KRename – The batch renamer for KDE

Version 3.0.1

Last updated: 17.07.04	Page 16 of 16

http://www.krename.net

Dominik Seichter

2004-05-23T09:15:03