#1 2007-05-29 12:02

Omnidragon
Member
Registered: 2007-05-29
Posts: 5

Comic numbering (folders into name)

Hello there i was wondering if you could help me as i know nothing about Pascal.
i would liek to know if there was a way to remane my comics and manga to remove all the crap from them

the structure i would need to navigate is Title - Volume - Chapter - page number
where title, Volume and chapter are all directories and sub-directories and pagenumber is the file

any help would be great

Omni

Offline

#2 2007-05-29 13:13

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

Re: Comic numbering (folders into name)

The code below should do the trick! big_smile

const
  DELIMITER = ' - ';

var
  Count: Integer;
  Parts: TStringsArray;

begin
  Parts := WideSplitString(FilePath, '\');
  Count := Length(Parts);
  if Count >= 5 then
    FileName :=
      Parts[Count-4] + DELIMITER +
      Parts[Count-3] + DELIMITER +
      Parts[Count-2] + DELIMITER +
      FileName;    
end.

renamercomicspathhs7.gif

Offline

#3 2007-05-29 13:50

Omnidragon
Member
Registered: 2007-05-29
Posts: 5

Re: Comic numbering (folders into name)

Thank you very much
is there away to do it so it looks like Title - V%n - C%n - pagenumber
where %n is the number but is generated by the number of folers that it has had to have been navigated with a seperate count for each type

Offline

#4 2007-05-29 14:22

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

Re: Comic numbering (folders into name)

Omnidragon wrote:

is there away to do it so it looks like Title - V%n - C%n - pagenumber,
where %n is the number but is generated by the number of folers that it has had to have been navigated with a seperate count for each type

??????????? hmm  Example maybe??

Offline

#5 2007-05-29 15:41

Omnidragon
Member
Registered: 2007-05-29
Posts: 5

Re: Comic numbering (folders into name)

say the folder structure was Bleach-> Bleach Volume 1-> Chapter1[M7]-> Bleach-01.jpeg
i would like the file name to become Bleach-V001-C001-01.jpeg

but there are currently 26 volumes and a varying number of chapters per volume and a varying number of pages per chapter
and i am trying to compile them in to a CBR(comic book Rar) for archiving and they all have different naming conventions

Offline

#6 2007-05-29 21:33

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

Re: Comic numbering (folders into name)

I cannot write a script for you, unless you describe the algorithm behind the rule that you want to create. Your explanation is very vague, can you please be more specific? For example: for "Bleach\Bleach Volume 1\Chapter1[M7]\Bleach-01.jpeg" you want "Bleach-V001-C001-01.jpeg". We get the name of first folder, then V and the first number out the folder, then C and the first number out of the folder, then just the first number of the filename?

Offline

#7 2007-05-29 21:39

Omnidragon
Member
Registered: 2007-05-29
Posts: 5

Re: Comic numbering (folders into name)

yep got it in one sorry about the poor explination

Offline

#8 2007-05-29 23:04

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

Re: Comic numbering (folders into name)

Here you go, it will do exactly as described in my previous post (plus it will pad all numbers to 3 digits). You can change the padding length and the delimiter by modifying the constants at the top of the script. The new code will produce "Bleach - V001 - C001 - 001.jpeg" for your example.

By the way, sorry for being so harsh. I was just dealing with recent popularity of my forum for SPAM-BOTS. I have integrated an image verification code in the registration page. This should slow down those bastards! wink

const
  DELIMITER = ' - ';
  PADDING_N = 3;

var
  Count: Integer;
  Parts: TStringsArray;
  
function ExtractFirstNumber(const S: WideString): string;
var
  I: Integer;
  IsDigit: Boolean;
  Started: Boolean;
begin
  Result := '';
  Started := False;
  for I:=1 to Length(S) do
  begin
    IsDigit := IsWideCharDigit(S[i]);
    if not Started and IsDigit then Started := True;    
    if Started and IsDigit then Result := Result + S[i];
    if Started and not IsDigit then Break;
  end;
end;

function PadStr(const S: string; NewLength: Integer): string;
begin
  Result := S;
  while Length(Result) < NewLength do
    Result := '0'+Result;
end;

begin
  Parts := WideSplitString(FilePath, '\');
  Count := Length(Parts);
  if Count >= 5 then
    FileName :=
      Parts[Count-4] + DELIMITER +
      'V' + PadStr(ExtractFirstNumber(Parts[Count-3]), PADDING_N) + DELIMITER +
      'C' + PadStr(ExtractFirstNumber(Parts[Count-2]), PADDING_N) + DELIMITER +
      PadStr(ExtractFirstNumber(FileName), PADDING_N) +
      WideExtractFileExt(FileName);    
end.

Tell me how it goes, ok?

Offline

#9 2007-05-29 23:09

Omnidragon
Member
Registered: 2007-05-29
Posts: 5

Re: Comic numbering (folders into name)

yeah i did notice 3-4 of them pop up earlier and its no worries i know how hard it can be to run forums

Offline

Board footer

Powered by FluxBB