#1 2022-09-04 21:19

Asa
Member
Registered: 2022-09-04
Posts: 3

keeping rename same for original same name w different extensions

Seems simple enough but I can't figure it out in trying out Renamer I have 6 files I want to rename:

Cyn 4a1k14a1a.tif,    Cyn 4a1k14a1b.tif,     Cyn 4a1k14a1c.tif, 
Cyn 4a1k14a1d.jpg,  Cyn 4a1k14a1d.png,   Cyn 4a1k14a1d.tif
                                     
rule #1  Insert:  Insert "art" replacing current name (skip extension)   
rule #2  Serialize: Incremental from 1 repeat 1 step 1 as Suffix (skip extension)

BUT when I want the prefix rename (art) to keep same serialized number
for files w same name but different extensions, I clueless what's next -- 
example:  art 1.tif,  art 2 .tif,  art 3.tif,  art 4.jpg,  art 4.png,  art 4.tif 
-- NOT      art 1.tif,  art 2 .tif,  art 3.tif,  art 4.jpg,  art 5.png,  art 6.tif

can't figure it out, any solutions? I tried filtering but couldn't get it to work.
Don't want to create subfolders for different extension types after rename. Thanks

Last edited by Asa (2022-09-05 04:02)

Offline

#2 2022-09-05 20:50

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

Re: keeping rename same for original same name w different extensions

Apply the following script (in the Pascal Script rule) to index files according to your requirement, keeping the counter same if the base file name doesn't change.

Don't forget to sort your files by the name column before applying the rule.

var
  Counter: Integer;
  PreviousBaseName, CurrentBaseName: WideString;
begin
  Counter := Counter + 1;
  CurrentBaseName := WideExtractBaseName(FileName);
  if Length(PreviousBaseName) > 0 then
  begin
    if WideSameFileName(CurrentBaseName, PreviousBaseName) then
      Counter := Counter - 1;
  end;
  PreviousBaseName := CurrentBaseName;
  FileName := IntToStr(Counter) + WideExtractFileExt(FileName);
end.

Offline

#3 2022-09-05 22:12

Asa
Member
Registered: 2022-09-04
Posts: 3

Re: keeping rename same for original same name w different extensions

wow, thank you so much --  I looked into learning Pascal script, but it's probably gonna be hard for a guy who's 69 with no background, I just saw this when I googled it --
"Pascal forces you to always think about data as having specific types. For a new programmer this is an excellent habit to develop."
At least I can apply your script. I have literally thousands of files with names that have approached the limit in characters (I do digital art and every time I did an iteration to the work I had to increase the name characters for ID and tracking purposes). If I can implement your code I'll buy ReNamer in gratitude, -- "The Pascal Script Rule", but of course - Again thank you so much.

Edit: I just realized how much more valuable ReNamer is by giving you the ability to implement Object Pascal code if you know it. For anyone interested there's a $16 beginner's intro tutorial complete w a 124 page EBook called "The Little Book Of Pascal", explains all the topics in depth  --  "Learn To Program with Delphi and Object Pascal" available here   
- Learn To Program with Delphi and Object Pascal

Last edited by Asa (2022-09-06 02:26)

Offline

#4 2022-09-06 16:15

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,127

Re: keeping rename same for original same name w different extensions

Here's another "Learn Pascal tutorial" page: https://www.taoyue.com/tutorials/pascal

Please note that we use PascalScript here, a subset of Pascal,
and not everything what is possible in PascalScript may be completely implemented into ReNamer too.

But see there to lookup what ReNamer is able to do >> https://www.den4b.com/wiki/ReNamer:Pascal_Script




 


Please see HELP and MANUAL in Wiki for more info.
If ReNamer had helped you, please donate a coin to Denis or buy a Pro license for commercial use. (Lite vs Pro)

Offline

#5 2022-09-06 18:45

Asa
Member
Registered: 2022-09-04
Posts: 3

Re: keeping rename same for original same name w different extensions

Thank you so much for the info. I'm trying to wrap my head around this coding stuff and any leads to helpful info is greatly appreciated. The PascalScript tip is pointing me in the right direction along with the ReNamer:Pascal Script link you cited. Thanks

Offline

Board footer

Powered by FluxBB