GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Alpabetic renaming


#1

I'm a photographer and want to use an alphabetic sequence for renaming image. Individual files will be distinguished by a two digit sequence of letters rather than numbers. Using just two characters I get 676 unique names for each job instead of 100 with numbers.
Can DOpus do this? Any help is much appreciated.
Thanks
Robert, Melbourne


#2

You mean "Hexavigesimal" (Base26) or "Hexatrigesimal" (Base36, fr.wikipedia.org/wiki/Base_36)? o)
Holy crap o): en.wikipedia.org/wiki/List_of_n ... al_systems

Surprisingly converting decimal to base36 is easy with jscript..

code.toString(36) ==> "1"
(10).toString(36) ==> "a"
(35).toString(36) ==> "z"[/code]
So a regular jscript should be able to do it.


#3

Thanks tbone for the prompt reply. That's a very powerful tool you've suggested, it opens up a world of possibilities. However like many others you've grossly underestimated the depth of my ignorance. I haven't yet scratched the surface of the power of Directory Opus and don't even know how to load and run a script. Is it under some menu? Is the script no more than a text file or must it have a specific file extension?
It would be great if you could point me in the direction of some basic instruction in getting started with scripts. I've downloaded many sample scripts but don't know what to do with them.
Thanks in advance
Robert


#4

In this case, I'd suggest you start with the manual and the scripting section. o) Then maybe look at some of the examples posted in the script addin area in this forum, most scripts feature brief instructions on how to install and use them. There's also a nice website at www.dearopus.com, which is worth reading in the beginning, it has a scripting section as well.


#5

thanks tbone


#6

@883robert,

I'm guessing you're not able to write the script, so if someone doesn't come along and provide one for you, I'll add the conversions to the Dynamic Renamer.

You'll just install it, select your files, choose it from the Rename presets, and enter a couple of characters in the New Name area (like -##b36) and it will rename your files using the base36 method mentioned by tbone. You can save your entry as a Preset, and then you'd just select it next time instead of Dynamic Renamer, and there's nothing for you to enter.


#7

That's great. You not wrong in guessing I'm not able to write the script. I look forward to downloading your script. I'm going to have to learn at least a little about scripting, at least enough to be able to modify your script. I want to limit the characters to letters of the alphabet. This gives me a sufficient number of unique file names (26 squared for two letters) while making the sequence number of two letters easily distinguishable from other characters (date or version number) as they will be numbers from 1 to 9.
More power to you MrC
Robert


#8

Sure thing.

What version of Directory Opus are you currently using (I see 11 in your sig)?

First, be sure you're OK with installing the required ActivePerl. The script code is written in Perl, so that package is required to allow it to run. Check out the instructions in the Dynamic Renamer page.

Second, do you want uppercase or lowercase letters?

Finally, are your files already numbered, or do you want to just append the sequence to the end?


#9

Extra AlphaCount.orp from this zip file, then import it into the Rename (Advanced) dialog via its File > Import... menu option.

AlphaCount.zip (547 Bytes)

It pads the counts to three characters. Edit the padLen = 3 line near the top of the script if you want different padding.

Works with both Opus 11 and Opus 12.

Here's the script code for reference. It uses the dialog's Sequential numbering from... options to prefix a normal decimal number to the start of each filename, then the script turns that into the alphanumeric number.

[code]function OnGetNewName(getNewNameData)
{
var padLen = 3;

var matches = /^(\d+)( .+)$/.exec(getNewNameData.newname);
if (matches == null)
	return;

var id = Number(matches[1]).toString(36);
id = pad(id, padLen);

var rest = matches[2];

return id + rest;

}

function pad(s, len)
{
while(s.length < len)
s = "0" + s;
return s;
}[/code]

Opus 11:


Opus 12 beta (new rename dialog won't look quite like this until we release beta 6; some new changes in the screenshot):



#10

I knew I could provoke Leo into providing you with a solution! :slight_smile:

I've updated the Dynamic Renamer to version 1.12. It supports your feature request, and more.

You supply a New name in the form of -# with optional additional flags. You can add more # characters to pad, use the ^ character to place the number at the front of the filename, and supply a number to indicate the numeric system you want to use. Example, to use hexidecimal, padded to 4 places, with the number at the front, you'd use -####^16


And to do your Hexatrigesimal system, padded to three places, use -###36


Add more transformations to do almost anything. Once you have the transformation chain the way you like it, save it as a Preset and it will be ready to use next time.


#11

Very nice! o)

Typo here: -###36 ?
Shouldn't it be: -###^36 ?


#12

Thanks. No typo.... The caret is the beginning of string flag. Without it, the number of placed at the end. It was just an example. I'm not sure where the OP wants the number, so provided a few example options.


#13

Ok, sorry! o) Never used DR myself, should take a look at it! o)


#14

Go man, Run, do not walk! :slight_smile:


#15

Man you guys are good. I'm like a dog with two tails. Watch out Digital Asset Management, there's no stopping me now.
Robert


#16

Coupla quick questions Leo:

  1. When I import the new preset via Advanced Renamer's File Import function no new preset appears in the preset list. I'm missing something.
  2. I notice the alphabetic numbering is padded with zeros. If I'm using letters a through to z, i.e. base 26, it would be better to pad them with an 'a'. Zero looks like an o and it's logically inconsistent anyway.
    When the rightmost character reaches 'z' it should return to 'a' and and the second rightmost character should tick over from 'a' to 'b'. The first character in a three character series is thus 'aaa' and the last is 'zzz', giving 26x26x26 variations.
    Does this make sense to anyone else or is it just me?
    Thanks again
    Robert

#17

In Opus 11, importing a .orp just loads it into the window. You then have to save the window's current setup as a Rename Preset if that's what you want.

In Opus 12, importing a .orp automatically adds it as a new preset.

New version that's base 26 instead of base 36:

AlphaCount_2.zip (593 Bytes)

New script for reference. (The starting number in the dialog was also changed from 1 to 0, so it starts at AA instead of AB.)

[code]function OnGetNewName(getNewNameData)
{
var padLen = 2;

var matches = /^(\d+)( .+)$/.exec(getNewNameData.newname);
if (matches == null)
	return;
var idNum = Number(matches[1]);
var rest = matches[2];

var idStr = "";
while (idNum > 0)
{
	var rem = idNum % 26;
	idNum = (idNum - rem) / 26;
	idStr = String.fromCharCode(65 + rem) + idStr;
}
while(idStr.length < padLen)
	idStr = "A" + idStr;

return idStr + rest;

}[/code]



#18

My, what a sexy rename dialog you have, sir. :slight_smile:


#19

Got it, works like a charm. Thanks Leo. Just one more thing:
When I'm on a job I take a few hundred photos and during a break upload them to my laptop. First thing I do is to rename them, even before making a backup. There's little worse than a file with two names.
So after the break I continue working. At the end of the shoot I upload the second lot and must specify the start number to avoid using names already used. If the last file name used was rgc_160527_agj.jpg (my initials, date in Australian format, alphabetic sequence) I want the next to be rgc_160527_agk.jpg. Now is agk 167 or 168 after start aaa?
It would be nice if the start number drop down box listed letters instead of numbers. Just dreaming.
And jon's right, it's one helluva sexy rename scheme. And I did it all just by asking...
Robert


#20

If you switch to the Opus 12 public beta I can do a version of the script that lets you enter the starting letters instead.

Could also do it in a slightly kludgey way for Opus 11 if you want to stay with that, but it can be done better with 12.

Do you want the numbers added at the end of the filename instead of the start?