#1 2013-04-05 23:44

Dirk
Member
Registered: 2013-04-05
Posts: 91

How can I enumerate files by groups? Serialize group-wise?

How can I enumerate file names like these ones in one step, starting with "1" each group (undefined amount of groups):

Crash_Canyon_12.08.25_17-55_viva_25_TVOF_XX.mpg.avi
Crash_Canyon_12.08.26_19-35_viva_25_TVOF_XX.mpg.avi
Crash_Canyon_13.03.05_20-45_viva_30_TVOF_XX.mpg.avi
Der_rosarote_Panther_12.08.25_09-15_sw3_5_TVOF_XX.mpg.avi
Die_Simpsons_12.06.15_18-10_pro7_30_TVOF_XX.mpg.avi
Die_Simpsons_12.06.15_18-40_pro7_25_TVOF_XX.mpg.avi
Die_Simpsons_12.06.16_18-10_pro7_30_TVOF_XX.mpg.avi
Die_Simpsons_12.06.16_18-40_pro7_25_TVOF_XX.mpg.avi

To:

Crash Canyon 1.mpg.avi
Crash Canyon 2.mpg.avi
Crash Canyon 3.mpg.avi
Der rosarote Panther 1.mpg.avi
Die Simpsons 1.mpg.avi
Die Simpsons 2.mpg.avi
Die Simpsons 3.mpg.avi
Die Simpsons 4.mpg.avi

For removing the characters after the series name I would use the rules form the other post here.

Offline

#2 2013-04-06 11:49

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

Re: How can I enumerate files by groups? Serialize group-wise?

This is a slightly modified "serialize duplicates" script which will append 1,2,3,etc to the end of repeated filenames. Paste this code into PascalScript rule as a last rule (after you've cleaned up the names). Make sure you sort by the original filename, so that the correct order is kept.

var
  Files: TStringsArray;

procedure Add(const S: WideString);
begin
  SetLength(Files, Length(Files)+1);
  Files[Length(Files)-1] := S;
end;

function Exists(const S: WideString): Boolean;
var I: Integer;
begin
  Result := False;
  for I:=0 to Length(Files)-1 do
    if WideSameText(Files[i], S) then
      begin Result := True; Break; end;
end;

var
  NewFileName: WideString;
  Counter: Integer;

begin
  Counter := 1;
  NewFileName := FileName;
  repeat
    NewFileName := WideExtractBaseName(FileName) + ' ' +
      IntToStr(Counter) + WideExtractFileExt(FileName);
    Counter := Counter + 1;
  until not Exists(NewFileName);
  FileName := NewFileName;
  Add(FileName);
end.

Offline

#3 2013-04-06 12:54

Dirk
Member
Registered: 2013-04-05
Posts: 91

Re: How can I enumerate files by groups? Serialize group-wise?

Many thanks,

Just works perfectly.

As I see, such kind of renaming is much more complicated as just to activate / deactivated some options in the "normal" settings users having any idea like me can make it.

Would that be possible: when you add new series to the already enumerated (with this script) / existing ones (in the same folder) the new ones could be automatically enumerated starting with the next number the last (already existing and renamed) video file of the same series is numbered, e.g. (all the existing and renamed files stay untouched):

Crash Canyon 1.avi
Crash Canyon 2.avi
Crash Canyon 3.avi
(they are kept like they are) already exist, now new files are added

Crash_Canyon_12.08.26_19-35_viva_25_TVOF_XX.mpg.avi
Crash_Canyon_13.03.05_20-45_viva_30_TVOF_XX.mpg.avi
Crash_Canyon_13.03.07_19-20_viva_25_TVOF_XX.mpg.avi
Crash_Canyon_13.03.07_20-15_viva_30_TVOF_XX.mpg.avi

and they are renamed to

Crash Canyon 4.avi
Crash Canyon 5.avi
Crash Canyon 6.avi
Crash Canyon 7.avi

and so on.

So, you always could rename by just one click (to start the preset renaming).

Many thanks again.

Offline

#4 2013-04-09 11:07

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

Re: How can I enumerate files by groups? Serialize group-wise?

Maybe the best solution would be to add them all together, already renamed files and the new ones. Clear their names and renumber from 1.

Offline

#5 2013-04-09 12:23

Dirk
Member
Registered: 2013-04-05
Posts: 91

Re: How can I enumerate files by groups? Serialize group-wise?

Yes, indeed, that would be the best, but there are always new files to be added.

<<<Clear their names and renumber from 1.
But that would mean, file number one becomes another file and when I wanted to access the old number 1 I would access another file.

Offline

Board footer

Powered by FluxBB