#1 2007-10-25 20:35

kingfenix
Member
Registered: 2007-10-25
Posts: 8

Comic numbering

If you have files such as the list below, how can you rename them to all have 3 digit issue numbers?

Comic Name 1.cbr
Some Really Amazing Comic Name 002.cbz
Comic 08.cbz

TIA,

KF

Offline

#2 2007-10-25 21:28

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Comic numbering

Hi king,

at least you could do this with two regular expression search & replace:


For Comic Name 1.cbr
Search for
space => \s
on single digit => \d => in brackets () for back referencing (\d)
end of name => $ ........ to capture only the last digit in name like "test 2king 3 fenix 4.txt"
[x] Skip extension

Search: \s(\d)$


Replace with
space
two zero's => 00
the captured digit => $1

Replace: 00$1


---

For Comic 08.cbz
Search: \s(\d\d)$
Replace: 0$1

---

HTH?
Stefan

Last edited by Stefan (2007-10-25 21:31)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2007-10-26 09:19

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: Comic numbering

You can use a predefined script from within PascalScript rule, which is called "Pad number sequences".

It does exactly what you need! To change the length of the new numbers - change PAD_TO_LENGTH constant.

Offline

#4 2007-10-28 15:21

kingfenix
Member
Registered: 2007-10-25
Posts: 8

Re: Comic numbering

Can you provide a example of the pascalscript to do so, I am afraid I dont know it very well

KF

Offline

#5 2007-10-28 15:22

kingfenix
Member
Registered: 2007-10-25
Posts: 8

Re: Comic numbering

DOH, sorry I understand now

KF

Offline

#6 2007-10-28 22:04

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: Comic numbering

That script comes together with the distributive of ReNamer wink

Just in case, I post the full script which I have mentioned:

const
  PAD_TO_LENGTH = 3;

function CountDigits(const S: WideString; StartI: Integer): Integer;
var I: Integer;
begin
  Result := 0;
  for I:=StartI to WideLength(S) do
    if IsWideCharDigit(S[i])
      then Inc(Result)
      else Break;
end;

function MakeZeros(Count: Integer): WideString;
var I: Integer;
begin
  Result := '';
  for I:=1 to Count do
    Result := Result + '0';
end;

var
  Start, Count: Integer;

begin
  Start := 1;
  while Start < WideLength(FileName) do
  begin
    Count := CountDigits(FileName, Start);
    if (Count > 0) then
      if (Count < PAD_TO_LENGTH) then
      begin
        WideInsert(MakeZeros(PAD_TO_LENGTH-Count), FileName, Start);
        Start := Start + PAD_TO_LENGTH;
      end
      else Start := Start + Count
    else Inc(Start);
  end;
end.

Offline

Board footer

Powered by FluxBB