#1 2007-08-06 11:56

ovo
Member
Registered: 2007-08-06
Posts: 2

ReNamer: how to insert the filename at a "right-to-left" position?

I would like to insert "sent_" before the last 3 digits,

From:
family_001.jpg
work_023.jpg
friend_098.jpg
day1_003.jpg
day24_050.jpg

To:
family_sent_001.jpg
work_sent_023.jpg
friend_sent_098.jpg
day1_sent_003.jpg
day24_sent_050.jpg

"Insert" only got a "left-to-right" position option,
so how could I do this by using other rules,
please help, thanks a lot.

Offline

#2 2007-08-06 13:10

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

Re: ReNamer: how to insert the filename at a "right-to-left" position?

Use PascalScript rule, and put this code:

const
  RIGHT = 3;
  TEXT = 'sent_';
var
  Position: Integer;
begin
  Position := WideLength(FileName) - WideLength(
    WideExtractFileExt(FileName)) - RIGHT + 1; 
  if Position < 1 then Position := 1;
  WideInsert(TEXT, FileName, Position);
end.

You can change the constants at the top of the script (RIGHT and TEXT).

Alternatively, you could use RegEx rule, to insert text before the last "_" (underscore), but that might get a bit complicated.

Offline

#3 2007-08-06 14:16

ovo
Member
Registered: 2007-08-06
Posts: 2

Re: ReNamer: how to insert the filename at a "right-to-left" position?

Thank you Denis, it works, but will you consider to apply such function to "Insert" for the coming version? It is a lot easier to rename it than using PascalScript. ^_^

Offline

#4 2007-08-06 20:25

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

Re: ReNamer: how to insert the filename at a "right-to-left" position?

I will consider it smile

Offline

Board footer

Powered by FluxBB