1 (edited by Borut 2012-04-13 07:40:04)

Topic: Name collision resolution

I have three wishes in the area of the name collision resolution...

A) I am using %ncs{1}. Is it possible to avoid the underline at the beginning?
B) Is it possible to use something I would call "alpha increment", for example:
    _01    _02   ...    _09    _10    _11  ...

    WISH, for instance %nca{2}:
    aa   ab   ...  az   ba  bb  ...

C) This could be the most difficult to achieve, because it defers from your "philosophy", I think... Currently, I think that "collision" is the collision between the current set of selected calculated names. I think that more correct would perhaps be, if it would be the collision with real files, that exist at calculation time. So, after the first calculation of the new name, to look in the file system if it already exists (and then, if %nc used, recalculate, look again in the file system,...).

I know - this is a major change, but I think it would be better.

Thank you for considering C and helping me to achieve A (or even B), if already possible.


EDIT: C is even more difficult, because I think the logic would need to check against both the file system and other already calculated values and there is no collision only if both cases are OK.

Re: Name collision resolution


A) You can use a string modifier to remove it.
For example : %ncs{1}("_","") or more simply %ncs{1}("_")

B) I thought you could use a combination of %T, %ncs and a text file containing the replacement alphabetic sequences.
But while testing a bug showed up ... It has to be fixed.

C) I won't get into this for the 3.00 release



Re: Name collision resolution

About your "B)" point.

Using Siren 3.00 build 888 (it corrects a bug present in previous versions), a way to solve this could be :

1) Create a text file containing the converted numbers you want to use.
In your case :

Let's say its name is "C:\sr_n2a.txt"

For test purpose I've created mine. I can send it you if needed.

2) Use an expression like : %b(1,1)%T{"C:\\sr_n2a.txt",%nc{1,0}}.%e

%b(1,1) : choose the collision part you want. For the test I've chosen the first character of the base name.

%T{"C:\\sr_n2a.txt",%nc{1,0}} : will extract the text lines from "C:\sr_n2a.txt" (don't forget to double the "\"),
The second parameter is the number of the line you want to extract. In this case it will be the collision number.
If this number is invalid (0 for example) the string returned is empty.
%nc{1,0} is the collision number non padded with zeros and starting at 0.
Therefore the first element of a collision group will have an empty identifier. The second will be "aa", the third "ab" ...

%e : is the extension of the name

3) If you want to add a separator between the two parts (for example a "_") and do not want it on the first element of the collision group then the expression can be :


_ : is inserted in the first sub-expression just before the "%T"

; : the semicolon separates the two sub-expressions

%b(s/_$//).%e : this second sub-expression will remove the last "_" of the base name

Hoping this will help.


4 (edited by Stefan 2012-04-24 19:32:37)

Re: Name collision resolution

Rémi wrote:

Let's say its name is "C:\sr_n2a.txt"
For test purpose I've created mine. I can send it you if needed.

If i may...
Copy this code to an plain text file with VBS extension and execute it to get such an sr_n2a.txt file:
(Note: this is Windows platforms only i think. But now i have an reason to start with python ;-) )


' Create char list "sr_n2a.txt" visual basic script
' '''''''''''''''''''''''''''''''''''''''''''''''''
' 97  = a
' 98  = b
' 99  = c
' ... = ...
' 122 = z
' For upper case chars A-Z use numbers 65-90 ( google for ASCII table to see why)
' '''''''''''''''''''''''''''''''''''''''''''''''''

' This 97-122 are 26*26=676 possibilities wit two chars aa-zz. 
' uncomment the two "X" lines to get even 26*26*26=17576 with three chars aaa-zzz

'For x = 97 to 122
    If x Then iteration = chr(x)

    For i = 97 to 122
        iter = chr(i)
        For c = 97 to 122
            OUT = OUT & iteration & iter & chr(c) & vbCRLF
        Next 'c
    Next 'i

'Next 'x
' '''''''''''''''''''''''''''''''''''''''''''''''''

ForWriting = 2
Set FSO = CreateObject("Scripting.FileSystemObject")
Set outfile = FSO.OpenTextFile("sr_n2a.txt", ForWriting, True)
MsgBox "Done. See sr_n2a.txt in same folder."


To create list with roman numbers use:



FOR i = 1 to 145
   OUT = OUT & Decimal2Roman(i) & vbCRLF

Function Decimal2Roman( ByVal intDecimal )
   ' COPY HERE THE        Function Decimal2Roman( ByVal intDecimal )
   ' FOUND AT             http://www.robvanderwoude.com/vbstech_data_roman.php
End Function
' '''''''''''''''''''''''''''''''''''''''''''''''''

ForWriting = 2
Set FSO = CreateObject("Scripting.FileSystemObject")
Set outfile = FSO.OpenTextFile("sr_Roman.txt", ForWriting, True)
MsgBox "Done. See sr_Roman.txt in same folder."


Note: this is Windows platforms only i think.
But now i have an reason to start with python ;-)

>>> for i in range(97,122):
...   for x in range(97,122):
...     print(chr(i),chr(x))
a a
a b
a c
a d
a e
a f
a g

Re: Name collision resolution

Thanks Stefan

6 (edited by Borut 2012-04-26 14:37:59)

Re: Name collision resolution

Regarding B:
Thank you Rémi, but I have not had time to test this yet. I will write a confirmation, as soon as I find some time to test it.

Regarding C:
I have a question: What happens if there is no name collision between currently evaluated names, and one executes copy (to copy originals to destination places) and there, in the file system, then actually are name collisions? I hope nothing will be overwritten and also hope that some error/problem information will be reported to the user.

(I understand that you will look into this problem after 3.00. I am just asking how it is now, because of the following scenario: Two persons were at the same time with their cameras on the same event and made many shots in the same second. Used expression resolves the names up to the second and resolves also name collisions between currently selected names. Person A saves the image files on the server (expression includes server directories). Person B then saves image files from his/her camera on the same server, using the same expression. What will happen? This could very well be a real world problem, but I have not investigated what will actually happen.)

Thank you for your time. With each day I feel I should donate something smile

Re: Name collision resolution

About C:
During the renaming/copy Siren doesn't do any magic.
It goes through the selected file list and simply calls the rename/copy system function with the current and new names.

During this operation if a file already exists your operating system should refuse to rename/copy and give back an error to Siren. Finally Siren will display a window summarizing all the errors, if any.
All the files for which a problem appeared are displayed with an orange like background color and when they have the focus the associated message is displayed in the status line.

Under Windows, you can try to achieve the same in a command line window without Siren using "copy" and "ren" commands.

Tell me if you need more information.

8 (edited by Borut 2012-04-29 17:26:38)

Re: Name collision resolution

Regarding B)

Seems to work - thank you for the explanation! One more request:


I am fond of portable programs and would like to store this small file in siren's directory itself and define its position in a fully portable way. I was looking among base variables and hoping to find a variable that would give me the directory in which siren.exe is located. I was not able to find it. Would it be possible to add such a variable (if it is really not existing already)? Maybe that is not much work?

I would like to use something like this:


Thank you for considering this addition!

9 (edited by Stefan 2012-04-30 11:45:56)

Re: Name collision resolution

Two ideas:

1.) Siren could first take an look into its own folder to find files.
%b(1,8) %T{"sr_n2a.txt",%nc{1,0}}.*

2.) Siren could set an own user-system-variable %SirenPath% which can be accessed with ${SirenPath}

But i have tested that with an batch

SET SiPath=%~dp0
ECHO SiPath: %SiPath%
START siren

SiPath: X:\Path\Siren3\

%b(1,8) %T{"${SiPath}sr_n2a.txt",%nc{1,0}}.*

and it seems i have no success
since i need doubled back slashes for such variables like %T,
but the system var only contains single back slashes.

Also i didn't had success with
%b(1,8) %T{"${UserProfile}sr_n2a.txt",%nc{1,0}}.*
due the same issue.


Can i set e.g. an favorite who search&replace in an system variable string?

Or an other convention like $${var} with doubled back slashes?

But then even this advanced batch didn't succeed:

SET SiPath=%~dp0
SET SiPath=%SiPath:\=\\%
ECHO SiPath is set to: %SiPath%
START siren

SiPath is set to: X:\\Path\\Siren3\\

%b(1,8) %T{"${SiPath}sr_n2a.txt",%nc{1,0}}.*

It seems the var is not expanded in that expression?
And i guess there is no eval() command?
%b(1,8) %T{eval(${SiPath}) + "sr_n2a.txt",%nc{1,0}}.*


BTW, i am talking about Win32 Windows here.



I found an work around:

Start Siren from an batch like this



START siren

Now the current folder of Siren is accessible by B: too.
Now use
%b(1,8) %T{"b:\\sr_n2a.txt",%nc{1,0}}.*

This B: mapping is valid till an pc restart
or till you give the command
subst b: /d

Or use an batch like

START /wait siren 
subst B: /D

which do that automatically.
The drawback is, the command window will stay open till you close Siren.


Re: Name collision resolution


Constant strings are simple text. A '%' or a '$' in them won't be seen as a variable or an environment variable prefix but simply as a '%' or a '$'.

I've added a "%Pe" variable (path to Siren's executable) which will allow you to do the trick.
One way to append some text to a variable is to use a regular expression modifier like in:

A way to solve this kind of issue with Siren's "free" syntax is to add a "eval" variable.
Maybe something like : %()
Between the "()" a full expression could be written.
I've to think a bit more about this.
Any comments are welcome.



PS: I've made the modification in the example help too to remove the useless title. Thanks.

Re: Name collision resolution

Rémi wrote:

I've added a "%Pe" variable (path to Siren's executable) which will allow you to do the trick.

Thank you! I am using it now and it seems to work as expected.

I am quite happy with your program now. It takes some time to define what one needs, but that is the expected cost of flexibility.

However, I have programming background myself. Therefore I believe that for many potential users your syntax will be prohibitively complex. Maybe it could help if you would add even more examples in the help and in the favourites in the future.


Re: Name collision resolution

Glad to know that a solution has been found.

About examples, what do you think is missing ?
If you've got remarks or suggestions, please post them.