DATA Plugin for Sophisticated Rename.

Manages string and integer data types at runtime.

Introduction.

Earlier SR versions could only keep some user data in conditionals, the data being accessible only for current file name. With this plugin you will be able to store string and/or integer data which will be accessible from the beginning to the end of the whole renaming process. An interesting feature is that you don't need to set the type of the data beforehand - you can treat any data both as integer and string (when it is possible).

Installation.

The plugin is already built into sr.exe. The distributive archive with demo files and examples can be downloaded from SR home page. It has the same folder structure as the main SR folder. So just copy all the files to the corresponding folders on your hard disk.

How it works.

A buffer will be temporarily created in the memory. It will contain lines like this:

year=2004
month=August
day=24
...

If you request "year" (DATA), you will get "2004" (VALUE).

The table of functions.

For all functions, use dll name "sr.exe".

Function
Keys
Description
initdata
Creates a new data and sets a new value.
Nothing happens if the data already exists.
If TYPE is not given, the data will be considered as string.
If VALUE is not given, an empty line will be accepted for string and '0' will be accepted for integer.
DATA
The name of the data to create.
VALUE
Optional. Value to set.
TYPE
Optional. Data type - STR for string or INT for integer.
setdata
Sets a new value to an existing data, overwrites the previous value.
If data doesn't exist, it will be created.
DATA
The name of the data to modify.
VALUE
Value to set.
adddata
Adds a new value to an existing data.
If the data doesn't exists, VALUE will be added to 0 for INT and to an empty line for STR.
If TYPE is STR, the value will be added as string ('5'+'3'='53', 'qwer'+'12'='qwer12').
If TYPE is INT, the value will be added as signed integer (add: 5+3=8, substract: 5+-3=2).
If TYPE is INT and at least one of the values is not integer, an error will occur ('qwer'+12=error)
If TYPE is not given, the data will be considered as string.
DATA
The name of the data to modify.
VALUE
Value to add.
TYPE
Optional. Data type - STR for string or INT for integer.
getdata
Does nothing (used to return a value only).
DATA
The name of the data.
All functions return the 'VALUE' result key. This key contains the final value of the data after the modification.

You can use other variables as input keys DATA and VALUE, for example, you may set absolute values or functions' names:

DATA=MYEXIFDATE|VALUE=2004|TYPE=INT
DATA=*XXV GET DATA NAME|VALUE=*XVR EXIF DATE YEAR XX|TYPE=INT

The external variables which call this plugin can be used as inputs for SR variables and conditionals.

Examples.

Example presets and tutorial files for this plugin can be found at the SR home page.

Example 1: cool counter.

Preset - presets\coolnum
Files - tutorial\coolnum\*.* or any other exif files.

Some time ago a user wrote and asked how to solve such a problem: there are a lot of digital photos with exif metadata. They should be renamed in the following way - first goes the full date (YYYYMMDD), then a counter, but there should be a separate counter for each day. We needed a specific plugin to store dates and the counter value for each date. Now this task can be easily done by means of this universal plugin.

First we create a data for YYYYMMDD information. It will be different for different days. We use 'setdata' to update it for each file in the list. There will be as many datas as we have different shooting days. If we want to begin with 000, we should insert data initialization to set the initial counter value to -1, it will be initialized only once for each date (initdata). But in this example we want to begin with 001, so we don't need to initialize a new data - it will be automatically set to 0 when we try to add 1 to it. The last step is to add 1 to the data with the name YYYYMMDD. The rest of the preset is intended to allign numbers to 3-symbols (001 instead of 1, 012 instead of 12, etc) We could have done it more easily with the help of conditionals, but one more example for DATA plugin won't be out of place here.

Example 2: move files to specific folders.

Preset - presets\coolmove
Files - tutorial\coolnum\*.* (with exif) and tutorial\coolmove\*.* (without exif) or any other photos with and without exif.

This is a more simple example. We need to move all the files with exif information to the exif date 'YYYYMMDD' folders and all the files without exif to the file date 'NOEXIF\YYMMDD' folders. The root folder for the renamed files should be asked before the processing. The folders should be created automatically.

Piece of cake! We create two data cells to join YYYY+MM+DD for exif and file dates, then we use conditionals to check the presence or exif. If there is no exif, we create "file date" folder, else we create "exif date" folder. One more conditional is used to add "NOEXIF" subfolder to the files without exif metadata..

Both presets were tried with more than 4200 photos - all works fine!