#1 2009-02-14 11:20

report
Member
Registered: 2009-01-05
Posts: 40

UserInput Letters a to zz

Since currently Renamer does not provide serialized letters yet, here is at least a partial solution. It relies on UserInput and provides the letters a..z, then aa..az, ba..bz,..., za..zz. Sorry, not more than 702 names.

Usage: UserInput | Options | Load from text file

If you use naming from a to zz frequently but not always, creating the rule afresh each time would be inconvenient and time consuming. Add Files changes the directory also of UserInput | Options | Load from text file. Therefore enable "Save rules configuration on exit, load on startup.", add the UserInput rule, always keep it, and just activate / deactivate it.

Adding letters starting from a different first letter requires to edit the rule and delete those letters before. If one stores the default rule, one should clone it, activate the clone, and edit only the clone.

Although this is by far not the easiest solution, it may be an alternative to using a second file numbering and renaming software just for the purpose of adding serialized letters as a suffix to, say, a constant file number as a prefix.

So maybe my sample reference file saves someone some work. The Pascal experts might have different suggestions, I'd guess. In the meantime, I continue to hope for serialized letters.

Copy the following and save it as a file with the name a_zz.txt in, e.g., the Renamer program directory. (I have proofread the list for typos once.)

a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
aa
ab
ac
ad
ae
af
ag
ah
ai
aj
ak
al
am
an
ao
ap
aq
ar
as
at
au
av
aw
ax
ay
az
ba
bb
bc
bd
be
bf
bg
bh
bi
bj
bk
bl
bm
bn
bo
bp
bq
br
bs
bt
bu
bv
bw
bx
by
bz
ca
cb
cc
cd
ce
cf
cg
ch
ci
cj
ck
cl
cm
cn
co
cp
cq
cr
cs
ct
cu
cv
cw
cx
cy
cz
da
db
dc
dd
de
df
dg
dh
di
dj
dk
dl
dm
dn
do
dp
dq
dr
ds
dt
du
dv
dw
dx
dy
dz
ea
eb
ec
ed
ee
ef
eg
eh
ei
ej
ek
el
em
en
eo
ep
eq
er
es
et
eu
ev
ew
ex
ey
ez
fa
fb
fc
fd
fe
ff
fg
fh
fi
fj
fk
fl
fm
fn
fo
fp
fq
fr
fs
ft
fu
fv
fw
fx
fy
fz
ga
gb
gc
gd
ge
gf
gg
gh
gi
gj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ub
uc
ud
ue
uf
ug
uh
ui
uj
uk
ul
um
un
uo
up
uq
ur
us
ut
uu
uv
uw
ux
uy
uz
va
vb
vc
vd
ve
vf
vg
vh
vi
vj
vk
vl
vm
vn
vo
vp
vq
vr
vs
vt
vu
vv
vw
vx
vy
vz
wa
wb
wc
wd
we
wf
wg
wh
wi
wj
wk
wl
wm
wn
wo
wp
wq
wr
ws
wt
wu
wv
ww
wx
wy
wz
xa
xb
xc
xd
xe
xf
xg
xh
xi
xj
xk
xl
xm
xn
xo
xp
xq
xr
xs
xt
xu
xv
xw
xx
xy
xz
ya
yb
yc
yd
ye
yf
yg
yh
yi
yj
yk
yl
ym
yn
yo
yp
yq
yr
ys
yt
yu
yv
yw
yx
yy
yz
za
zb
zc
zd
ze
zf
zg
zh
zi
zj
zk
zl
zm
zn
zo
zp
zq
zr
zs
zt
zu
zv
zw
zx
zy
zz

Offline

#2 2009-02-14 13:54

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: UserInput Letters a to zz

Thanks for the list! I too would like alphabetic serialisation in ReNamer, but till then, this will have to do.

BTW, how did you create the list? Did you type in all 702 lines manually? 25i4rau.gif

Here's a little help for people who want to create a list of arbitrary length:

  • Start MS Excel.
     

  • In the first cell, enter this formula exactly:
     
    =CHAR(MOD(ROWS($1:1)-1,26)+97)
     
    to get the letter a.
     

  • Move the mouse to the bottom right corner of the cell till it becomes a + (plus), then left click and drag the mouse down.
     

  • Release to fill in the rest of the letters automatically, i.e. b, c, ..., z, a, b, ... and so on.
     

  • Use the following formula exactly:
     
    =CHAR(INT((ROWS($1:1)-1)/26)+97)&CHAR(MOD(ROWS($1:1)-1,26)+97)
     
    to get the series aa, ab, ac, ..., az, ba, bb, ..., bz, ... and so on.
     

  • To edit the formula of any cell, either select it and press F2, or else double-click it.
     

  • To get capital letters instead of small, change the number 97 in any formula to 65. So for example to get A, B, ..., Z, A, B, ... and so on, change the formula above from:
     
    =CHAR(MOD(ROWS($1:1)-1,26)+97)
     
    to
     
    =CHAR(MOD(ROWS($1:1)-1,26)+65)

This technique should prevent mistakes and save loads of time, as you can be sure of no errors/duplicates and so no need to proof-read. smile

Offline

#3 2009-02-14 16:36

report
Member
Registered: 2009-01-05
Posts: 40

Re: UserInput Letters a to zz

Well, almost did I type 702 manually. The only trick was to copy and paste ab..z and then insert the current first letter each time by pressing down key, left key, and typing that letter... Yes, nasty work it was :)

I had expected that there must be automatic ways of typing but I figured that I would need more time to find out than to type 702 lines. Thank you anyway, although I use OpenOffice rather than Excel.

Offline

#4 2009-02-14 18:59

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: UserInput Letters a to zz

I've been fiddling on my own for this issue (not that I really need it, but it's an exercise in PascalScript), I came up with something that may be close to what you're looking for. It's probably closer to the original spirit you wanted your alphanumeric serialize to be, but here it is anyway.

const
  LETTERS = 'abcdefghijklmnopqrstuvwxyz';
  NUMBERS = '0123456789';
  BOTH = '0123456789abcdefghijklmnopqrstuvwxyz';
  ALPHA_FORMAT = 'ln';

function AlphaSerialize(const i: Integer; const structure: String): String;
var
  single: Char;
  letterset: String;
  format_char: Char;
  format_r: String;
begin
  if (length(structure) > 0) then
    format_char := structure[length(structure)]
  else
  begin
    if (i = 0) then
    begin
      result := '';
      exit
    end
    else
    begin
      result := inttostr(i);
      exit
    end
  end;

  if (format_char = 'l') then
    letterset := LETTERS
  else
  begin
    if (format_char = 'b') then
      letterset := BOTH
    else
      letterset := NUMBERS
  end;

  single := letterset[(i mod length(letterset)) + 1];
  format_r := copy(structure, 1, length(structure) - 1);
  result := AlphaSerialize(i div length(letterset), format_r) + single;
end;

var
  Initialized: boolean;
  I: Integer;
begin
  if not Initialized then
  begin
    I := 1;
    Initialized := True;
  end;
  FileName := FileName + AlphaSerialize(I, ALPHA_FORMAT);
  I := I + 1
end.

Here, you define a format string for the alphanumeric serialization you want... 'l' for letters (that's a letter L), 'n' for numbers, and 'b' for both. And if you have serialization which extends longer than the format string specifies... well, you get numbers out front, though I suppose a few tweaks, you could change that to letters to match what you accomplished with your a_zz.txt smile

Offline

#5 2009-02-14 19:14

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: UserInput Letters a to zz

Nice script! You're a very good programmer prologician. smile

BTW, the letters are tacked on after the extension. Ignoring the extension might be preferred, in which case this line should work:

FileName := WideExtractBaseName(FileName) + AlphaSerialize(I, ALPHA_FORMAT) + WideExtractFileExt(FileName);

Also, if I specify ALPHA_FORMAT as 'll', it starts from 'ab' rather than 'aa'. Can you correct that?

Offline

#6 2009-02-14 19:19

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: UserInput Letters a to zz

Hehe, so you caught me with some degree of laziness. Oh, well. wink

The second point was the setting of the initial value... so, switched it to 0 instead of 1, and that should do it. smile

The new version:

const
  LETTERS = 'abcdefghijklmnopqrstuvwxyz';
  NUMBERS = '0123456789';
  BOTH = '0123456789abcdefghijklmnopqrstuvwxyz';
  ALPHA_FORMAT = 'll';

function AlphaSerialize(const i: Integer; const structure: String): String;
var
  single: Char;
  letterset: String;
  format_char: Char;
  format_r: String;
begin
  if (length(structure) > 0) then
    format_char := structure[length(structure)]
  else
  begin
    if (i = 0) then
    begin
      result := '';
      exit
    end
    else
    begin
      result := inttostr(i);
      exit
    end
  end;

  if (format_char = 'l') then
    letterset := LETTERS
  else
  begin
    if (format_char = 'b') then
      letterset := BOTH
    else
      letterset := NUMBERS
  end;

  single := letterset[(i mod length(letterset)) + 1];
  format_r := copy(structure, 1, length(structure) - 1);
  result := AlphaSerialize(i div length(letterset), format_r) + single;
end;

var
  Initialized: boolean;
  I: Integer;
begin
  if not Initialized then
  begin
    I := 0;
    Initialized := True;
  end;
  FileName := WideExtractBaseName(FileName) + AlphaSerialize(I, ALPHA_FORMAT) + WideExtractFileExt(FileName);
  I := I + 1
end.

And... tankoo for the compliment. big_smile

Offline

#7 2009-02-14 20:26

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: UserInput Letters a to zz

Hmmm...
Someone was firs... Nice job Prologician big_smile

Mine version is simpler... It only goes throug letters without padding... But I'll post it anyway. Just as an exercize.

var
  i, k,p: Integer;
  Letters : string;
  Pad: Array[1..100] of Integer;
  Initialized: Boolean;
  Serialization : String;


function CheckZ(p: Integer): Boolean;
begin

if Pad[p] >= Length(Letters) then
begin
  Pad[p]:=1;
  if p > 1 then
  begin
    Pad[p-1]:=Pad[p-1]+1;
    CheckZ(p-1);
  end
  else
    result := True;
end;

end;



begin
  if not Initialized then
  begin
    Initialized := True;
    Letters := 'abcdefghijklmnopqrstuvwxyz';
    i := 1;  
    p := 1;
  end;
  
  if i > Length(Letters) then
  begin
    i:=1;
    if CheckZ(p) = true then p:=p+1; 
  end;
 
  Pad[p]:=i;


  Serialization:='';
  for k:=1 to p do
    Serialization:=Serialization + Letters[Pad[k]];
  
  
  FileName := WideStripExtension(FileName) + Serialization + WideExtractFileExt(FileName);  
  i := i + 1;
end.

Last edited by krtek (2009-02-14 20:41)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#8 2009-02-14 20:32

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: UserInput Letters a to zz

Nice krtek! So this goes from a-z, aa-az, ba-bz, ...,  za-zz, then to zza and so on?

Offline

#9 2009-02-14 22:03

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: UserInput Letters a to zz

I tested krtek's script with an abbreviated alphabet (basically just the letters 'a' through 'e'), and I see two things. First, it looks like the script only handles up to two letters at the moment. Additionally, it doesn't go through the final letter when it's the leading letter (that is, when it hits 'de' using my abbreviated alphabet, it is followed by 'aa' again instead of 'ea').

Offline

#10 2009-02-15 08:26

report
Member
Registered: 2009-01-05
Posts: 40

Re: UserInput Letters a to zz

A quick and dirty test of prologician's second script lets it appear pretty useful, thank you! The constants at the top can be changed easily. Further constants might be introduced and then treated in the if...else section.

Offline

Board footer

Powered by FluxBB