#1 Yesterday 23:09

w84jon
Member
Registered: Yesterday
Posts: 1

How to add numbers if certain phrase present in the name

What steps would I take to add 01_ to the beginning of filenames that have the letters "gen"? (eg. txy_gen_text_reg.usfm)

01_ if gen
02_ if exo
03_ if lev
04_ if num
05_ if deu
06_ if jos
07_ if jdg

40_ if mat
41_ if mrk
42_ if luk
43_ if jhn
44_ if act

I would set up a total of 66 such rules. Each of the files would have only one of those 3 letter combinations in their filename.

I've never used ReNamer before.

Offline

#2 Today 10:21

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

Re: How to add numbers if certain phrase present in the name

You could use the Regular Expressions rule to creates such rules, one for every match.

But it might be simpler with a single Pascal Script rule, like so:

var
  Prefix: WideString;
begin
  Prefix := '';

  if WidePos('gen', FileName) > 0 then
    Prefix := '01_'
  else if WidePos('exo', FileName) > 0 then
    Prefix := '02_'
  else if WidePos('lev', FileName) > 0 then
    Prefix := '03_'
  // ADD MORE HERE ...
  else if WidePos('jhn', FileName) > 0 then
    Prefix := '43_'
  else if WidePos('act', FileName) > 0 then
    Prefix := '44_';

  if Length(Prefix) > 0 then
    FileName := Prefix + FileName;
end.

Offline

Board footer

Powered by FluxBB