You are not logged in.
Pages: 1
Hello,
is it possible with Renamer to replace a number by (itself + 1)?
Like 1444 by (1444 + 1) = 1445.
I have a lot of PSD files named like this :
1434_A_M5066-MDP-00061398-ORI2_Shad.psd
1434_R_M5066-MDP-00061399-ORI2_Shad.psd
1436_A_M5066-MDP-00060863-ORI2_Shad.psd
1438_A_M5066-MDP-00060917-ORI2_Shad.psd
and I would like to increment the first 4 digits by 1
1435_A_M5066-MDP-00061398-ORI2_Shad.psd
1435_R_M5066-MDP-00061399-ORI2_Shad.psd
1437_A_M5066-MDP-00060863-ORI2_Shad.psd
1439_A_M5066-MDP-00060917-ORI2_Shad.psd
Thanks
Last edited by NexusFred (2022-11-27 16:26)
Offline
Hi.
Can you just delete the first four signs
https://www.den4b.com/wiki/ReNamer:Rules:Delete
and next add a new serialization starting at 1435 ?
https://www.den4b.com/wiki/ReNamer:Rules:Serialize
?
If the numbers are not in sequence and if you are familiar with regex, you could try
ReNumber rule: Increase / Add , Decrease / Substract number digits
https://www.den4b.com/forum/viewtopic.php?id=2318
if that still works...
I also can take a look later on and guide you with the regex.
There is also mentioned this idea:
1. Using Excel
(In ReNamer add a rule to get the first four sings, export that, import in excel,
in Excel add a formula to increase value in column A by one into column B, export from Excel)
2. Add Rule > User Input
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Thanks a lot for your reply.
I think I will Rearrange the filename to put my digits at the end of it, and then use the Pascal script build by Stefan.
Offline
You don't have to rearrange you filenames.
As stated by Stefan you could do what is needed with Pascal Script. The ReNumber script from Stefan will do this properly. But as an universal solution there is lot of code to achieve this.
In your case you "just" want to find the first number in the filename, extract it as number, adjust it and write it back to the filename.
Have a look at this shorter script to get an idea off how to start. Often it turns out that there are more special cases on some filenames which have to be handled too ...
const
// Find number in right context:
//
// In this case the first match of a number of any length (\d+).
// To build the new string, we also catch everything before and
// after the number with (\D*) and (.*) repectively.
PATTERN = '(\D*)(\d+)(.*)';
// The amount for adjusting the number
OFFSET = 1;
var
Matches : TWideStringArray;
begin
Matches := SubMatchesRegEx(FileName, PATTERN, true);
if Length(Matches) > 0 then
begin
FileName := Matches[0] + Int64ToStr(StrToInt64(Matches[1]) + OFFSET) + Matches[2];
end;
end.
The line where FileName is assigned a new value is also doing the arithmetics. In this case OFFSET is added.
Offline
Thanks a lot for this script !!
Offline
Pages: 1