#1 2007-08-26 14:33

74hct245
Member
Registered: 2007-08-26
Posts: 2

How to increment number in the filename

Hello, compliments for your project "ReNamer".

It is possible to sum a value?

Example: I have this file name:
09109101.tif
09109107.tif
09109118.tif
09109121.tif
09109191.tif

I would to sum the value 33 on last three right characters so the result is:
09109134.tif
09109140.tif
09109151.tif
09109154.tif
09109294.tif

Thanks

P.S.

I do not have understand how to rename only directory names and subdirectory (no file name)

Offline

#2 2007-08-26 16:48

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

Re: How to increment number in the filename

Thanks smile

For your task, use PascalScript rule with the script below.

NOTE: Don't forget to sort by name in the REVERSE order, otherwise you might get collisions when you start renaming.

const
  ADD = 33;

var
  Value: Integer;
  Base, Ext: WideString;
  
function PadLeft(N, Len: Integer): string;
begin
  Result := IntToStr(N);
  while Length(Result) < Len do
    Result := '0'+Result;
end;

begin
  Ext := WideExtractFileExt(FileName)
  Base := WideExtractBaseName(FileName)
  Value := StrToIntDef(Base, -1);
  if Value > 0 then
  begin
    Base := PadLeft(Value+ADD, Length(Base));
    FileName := Base + Ext;
  end;
end.

Offline

#3 2007-08-26 16:50

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

Re: How to increment number in the filename

If you want to rename just directories (folders), open "Filter Settings", and use option "Add folders as files".

Offline

#4 2007-08-26 19:07

74hct245
Member
Registered: 2007-08-26
Posts: 2

Re: How to increment number in the filename

Thanks!!

Offline

Board footer

Powered by FluxBB