Sophisticated Rename manual

Prev Page Next Page


The following lessons will show you how to work with all SR datatypes. To try these demos you will need sample files included to this distributive pack (if you installed the software to the default folder you will find them in "c:\program files\sophisticated rename\tutorial").

Lesson A. Constants and counters.
Lesson B. Variables and extra variables.
Lesson C. Conditionals.
Lesson D. Managing the most difficult cases.
Lessons E, F and G. External variables.
Lesson H. Sorting files with "Custom paths" feature.
Lesson I. Using folder/file name information to save ID3 tags for MP3 files.
Lesson J. Using folder/file name information to save EXIF tags for JPG files.


Lesson-A. Constants and counters.

Add the files for lesson-A (see the 'tutorial' subfolder of the program) to the SR file list. Create an ascending counter from 1 to 32000. Set the number of digits = 3. Save the counter as "MYCOUNT". Press [Add item] in the main window (Template section), and add the counter to the template. Then add " - " as a constant. Now add "*XVR FILE NAME". The result will be something like that:

asd.txt -> 001 - asd.txt
qwerty.doc -> 002 - qwerty.doc
zxcv.exe -> 003 - zxcv.exe

If you was not able to achieve the correct result, open the preset called "lesson-A" and see how it should be done.


Lesson-B. Variables and extra variables.

The task is to rename the files IMG_1650.JPG, IMG_2280.JPG, IMG_2537.JPG using their metadata according to the template:

YYYY - year, MM - month, DD - day, MAKER - manufacturer, NUM - number from the name. Let's make it more difficult: if the maker string has several words, we will take only the first one.(I mean OLYMPUS OPTICAL CO.,LTD). And let's change the case as well.

OK, add the files for lesson-B to the empty list (see 'tutorial' folder). Go to the Var editor and create "*VAR NUM", first symbol from right = 4. (Alternative method: begin pos str = '1234567890' as a set of symbols, from left). Press [Add] and [New]. In the source field select "*XVR EXIF MAKE". End str = ' ' (space) from left to right, "cut end str" is checked to get rid of the space character if it exists. Add the var as "*VAR MAKE". Go to the main menu and add the following items to the template:

And this is the result:

2003-03-08 Olympus (1650).jpg
2004-02-01 Canon (2280).jpg
2004-04-07 Canon (2537).jpg

If you experienced any problems, open the "lesson-B" preset.


Lesson-C. Conditionals.

The task is to rename files for lesson-C in such a way: if the name contains digits, add zeros so that the length of the new name will be eight. If the name doesn't contain digits, do the same thing but with dashes instead of zeros (see table).

The task is easy to solve. A conditional determines if there are digits in the name, and if there are some, it adds 7 zeros to the beginning of the name, otherwise it adds 7 dashes. A variable is created to limit the number of symbols to 8.

234.txt 00000234.txt
5367.txt 00005367.txt
7.txt 00000007.txt
90210.txt 00090210.txt
123456.txt 00123456.txt
abc.txt -----abc.txt
qwerty.txt --qwerty.txt
bober.txt ---bober.txt
lkjhgfds.txt lkjhgfds.txt
ka.txt ------ka.txt

If you cannot achieve such a result yourself, load "preset-3" and learn how it works.


Lesson-D. Managing the most difficult cases.

Renaming the files for lesson-D (see tutorial folder):

Beaver13 Apr 2001 beaver's hut - animals.jpg
Moon-9 Dec 1998-very dark - nature.jpg
Sombody's birthday 10 Feb 2004poor quality - my friends.jpg

This is what we want to get:

2001-04-13 [Animals] Beaver (Beaver's Hut).jpg
1998-12-09 [Nature] Moon (Very Dark).jpg
2004-02-10 [My Friends] Sombody's Birthday (Poor Quality).jpg

Try to do it yourself, and if you fail, read the explanations.

There are four parts in these names: date, group, name and comment. It's easy to get the comment - it is in the last position and there is a dash before it. This dash is the first from the right side. It's also easy to get the date - the digits aren't used for anything else in this example. Anything else is more difficult. The second file doesn't have a leading zero in its date, we'll have to create a condition. Changing the names of months to numbers are other 12 conditions. The date is separated from name and comment by means of different symbols, and in the 'beaver' and 'birthday' cases there are no separators at all. So it's necessary to create other 2 conditions. If these hints didn't help, open the preset called "lesson-D" and follow these steps:
1) "*VAR GROUP" is for the group
2) "*VAR NAME MINUS LAST" is for the name without the last letter if it is merged with the number.
3) "*VAR NAME LAST" - the symbol before the "day".
4) "*CON NAME LAST": if "*VAR NAME LAST" is one of the separators (a dash or a space), then there will be no result else the result is this symbol.
5) Repat 2-4 for the first name of the comment (*VAR COMMENT MINUS FIRST, *VAR COMMENT FIRST, *CON COMMENT FIRST).
6) "*VAR YEAR" - year. "*VAR MONTH"- /literal/ month.
7) "*CON MONTH 02" Converting literal month to a number. You should create 12 conditions, but in this case I created only 3 to save my time.
8) The first and the last digit of the "day" - "*VAR DAY LAST" รจ "*VAR DAY FIRST".
9) (*CON DAY FIRST): if first symbol of day is digit, it will be the result, else returning "0".
10) Creating the template.


Lessons-E, F and G. External variables.

To understand this stuff read the comments in the source files ("external" subfolder).

LESSON-E. Plugin for beginners ;-) It's easy to create such a plugin for the nonce. It will work only if you place it to the same folder where sr.exe is. This simple plugin just gathers modification date of a file and sends back 3 values: year, month, day. If you want to create a professional plugin for distribution, see lesson F example.

LESSON-F. This example shows how to write professional plugins for distribution. The code is more difficult but it will work form any location, no matter where sr.exe is. This plugin generates random sequences. It uses 3 keys: "cnt", "min" and "max" to control the process. Examples: '110011110100101', '651084312', 'ABCCBABBABBCA', 'ienmgus' and so on.

LESSON-G. This task is more complicated. It is a kind of stepping counter when there will be a separate counter for each folder. It's just an example, if you need such a modification, it's better to use the internal SR counter. This example shows how to keep some data between executions of the program. A temporary buffer will be created for the nonce and at the end of processing it will be deleted. To determine the last execution of the program, we use *XVR LIST NUMBER and *XVR LIST TOTAL xvars. When they are equal, it means that it is the last file that is being processed. The only keyword is 'digits' that specifies the number of digits in the counter.


Lesson-H. Sorting files with "Custom paths" feature.

Suppose you have a lot of digital photos with exif metadata (files for lesson-H in the tutorial folder; there you find only 4 files to reduce the size of the distributive). The structure of the file names is "location dash number":


The task is to create a separate folder for each day of schooting using metadata and copy the files to these folders. The name of each folder should contain the shooting date and the location name and a filename should contain the location name and a 3-digit number:

2003-07-30 - Dacha
-> Dacha-007.jpg
2004-11-26 - Izmaylovo
-> Izmaylovo-023.jpg
2004-08-20 - Vladimir
-> Vladimir-002.jpg
-> Vladimir-014.jpg

This thing can be done using "custom paths" feature. All we have to do is add the required items to the template, dividing the folder items from the file items by the "\" symbol. In this example we create subfolders in the folder of original files ("*XVR FILE PATH"), but we can easily create them in some fixed place, providing an absolute path, for example "c:\sorted_files\". If you have any questions, open the "lesson-H" preset.


Lesson-I. Using folder/file name information to save ID3 tags for MP3 files.

A user wrote once and described such a situation: he had numerous sorted mp3 files without ID3 tags. These tags are used to show the artist name and the song title when the file is played in a mp3 player such as WinAMP. He suggested to use SR vars to get this data from the folder/and file name structure. It can be done with the help of the ID3 Updater. All you have to do is specify vars according to your specific folder/file structure. For example, this is how many mp3 files are stored:

\My Music\Alphaville\1997 Salvation\01 - Inside Out.mp3

Alphaville - artist;
1997 - album year;
Salvation - album name;
01 - track number;
Inside Out - song title.

This structure will be used to show you the way you should proceed in the most general way. First, drag'n'drop the files for lesson-I to the form (see "tutorial" folder). You should drag the whole "My Music" folder, not just some files. The folder contains 3 artists and 5 albums, total 30 files (some files were removed because trial version can handle only 30 files at once - if you have already registered, you can process thousands of files using the same scheme). The sample files are empty - they don't have neither music data nor ID3 tags - we don't need any data right now (except correct file names), on the contraty, we want to save ID3 tags to these files. Now open "lesson-I" preset. It has an empty template because the only purpose of this preset is to keep information about variables. Call ID3 updater (F8). At the right-bottom corner of the window press a small "load" button. Select "lesson-I". The fields of ID3 editor will be filled with the names of the variables that are described in the preset. You can see that the ID3v2 part is turned off - it's just because you work with empty files at the moment and ID3v2 requires real mp3 files. So, click [Apply] in the ID3 Updater and go to ID3 Viewer to see that all these files have correct tags.

Be creative - don't despond if you have another folder/file structure - all you have to do is adjust a few variables. If you have problems with it, feel free to contact Acritum support team.


Lesson-J. Using folder/file name information to saveEXIF tags for JPG files.

Suppose you have a lot of logically sorted pictures and you want to add some information from the file and folder names to the exif record of all photos. This can be easily done in Exif Updater. Exif Updater supports all SR datatypes, so all you have to do is extract required data to SR conditions and variables. Here is an example. We have a collection of well-known pictures that can be found in museums. The pictures don't have exif at all but they are properly sorted:

C:\Pictures Collection\The Hermitage\Paul Gauguin - Idol (1898).jpg
C:\Pictures Collection\The Hermitage\Claude Monet - Lady In The Garden (1867).jpg
C:\Pictures Collection\The Pushkin Museum of Fine Arts\Pablo Picasso - The Rendez-vous (1900).jpg
C:\Pictures Collection\The Pushkin Museum of Fine Arts\Caspar David Friedrich - Mountain Scenery (1810-1820).jpg
C:\Pictures Collection\The Tretyakov Gallery\Viktor Mikhailovich Vasnetsov - The Bogatyrs (1898).jpg
C:\Pictures Collection\The Tretyakov Gallery\Ivan Ivanovich Shishkin - Sunlit Pine-trees, Sestroretsk (1886).jpg
C:\Pictures Collection\The Tretyakov Gallery\Ivan Ivanovich Shishkin - Dubki (1886).jpg
C:\Pictures Collection\The Tretyakov Gallery\Isaak Ilyich Levitan - March (1895).jpg
C:\Pictures Collection\The Tretyakov Gallery\Ilya Yefimovich Repin - Ivan the terrible and his son Ivan on November 16th, 1581 (1895).jpg

Of course, you can add tags manually for these 9 images, but suppose you have 9000 images - it's unlikely you find it reasonable even to start the manual work! Our task is to add the following tags:

ImageDescription - picture name;
Artist - the name of the artist;
Copyright - the year and the museum name in the form: "XXXX, property of YYYY". Here is an example for the first picture:

ImageDescription = Idol
Artist = Paul Gauguin
Copyright = 1898, property of The Hermitage

To complete the task you have to specify vars for artist name, picture name, year, museum name and a couple of conditions to join year, "the property of" text and the name of the museum - you already know that it's all easy. Then go to Exif Updater and enter the names of vars right to Advanced Tags edit fields. As the jpg files don't have exif record at all, you will be able to add your new tags only in Exiv2 mode, so make sure that you have installed it. After it you can start the process and see results in any Exif viewer.

If you don't get successful results, load "lesson-J" preset in the main window and lesson-J preset in the Exif Updater - you will be able to find out how it all works. The files for this lesson can be found in the Tutorial folder.

Go to the main page.