You are not logged in.
Can someone help me develop a Pascal ReNamer script to sequence the following filenames up or down by 1, 2, or as many whole numbers as needed. Here is the file naming structure I am working with. These are filenames of engineering drawings and the last two digits before the file extension represents the revision state of the drawing. The filename will always be at least 16 characters long in this format and may or may not end with one or more letters. Only the numbers in the 15th and 16th position after the last hyphen will change.
Original Filenames
Z-1-89101-001-08.pdf
Z-1-89104-004-06.pdf
Z-1-89120-001-09b.pdf
Z-1-89120-012-00.pdf
Renamed to sequence +1 (add 1)
Z-1-89101-001-09.pdf
Z-1-89104-004-07.pdf
Z-1-89120-001-10b.pdf
Z-1-89120-012-01.pdf
Or renamed to sequence -1 (subtract 1)
Z-1-89101-001-07.pdf
Z-1-89104-004-05.pdf
Z-1-89120-001-08b.pdf
Z-1-89120-012-00.pdf (if the filename ends in -00 it is a brand new drawing and cannot go any lower on the revision state so it would be unchanged by sequencing down by 1)
I really appreciate any of your time and support developing this script.
Thank You,
Damon Deaton
Offline
Hi and welcome.
FROM:
Z-1-89104-004-06.pdf
Z-1-89120-001-09b.pdf
Z-1-89120-001-09More.pdf
TO:
Z-1-89104-004-07.pdf
Z-1-89120-001-10b.pdf
Z-1-89120-001-10More.pdf
TRY:
that PascalScript
http://www.den4b.com/forum/viewtopic.php?id=2318
ReNumber rule: Increase / Add , Decrease / Substract number digits
with U S E R S E T T I N G S for your case
//// RegEx pattern:
//// Split file name (without the extension) into parts (needs to be adjusted by user depending on file name pattern):
// Z-1-89104-004-06.pdf
// Z-1-89120-001-09b.pdf
// Z-1-89120-001-09more.pdf
strRE := '^(.+-)(\d+)(\D*)$';
// MIND the CASE of the RegEx-Expression! ( \d <> \D )
//// WorkOnPart:
//// On which part of the split file name do you want to work:
intPart := 2;
////Wanted amount to add / increase (or to subtract / decrease):
intAmountToCalc := 1;
////Math, do you want to add or to subtract:
/// use "add" -or- "sub" -or- "fix":
strDirection := 'add';
////Wanted length of the new number, taken from the right, add zero on the left if need:
////(Use "intNewNumberLength := 0;" to disable this feature)
intNewNumberLength := 2;
////Add underscore signs before and after new number for better identifying in the preview?
//// True: Yes, please add them. // False: No, not need at all.
boolDebugOutname := False;
////Allow Negative Result?
//// True: Yes, please allow (e.g.: -3). // False: No, use zero '0' instead.
boolAllowNegativeResult := false;
////Show message box with details from current step in code:
boolDebugShowmessage :=false;
////Prevent duplicated file names, add a string, remove that afterwards yourself in a second run:
//// (Use a sign or string which is not a part of existent file names)
strDuplicate := '#'
//// /END of user settings
- - -
Add a second rule to remove the '#'-sign again afterwards.
http://www.den4b.com/wiki/ReNamer:Rules:Remove
Did that work for you?
Last edited by Stefan (2021-10-05 16:41)
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
Thank you for your assistance in developing this script. I found another script in the forum database that I was able to modify to get the result I was looking for and it seems to work very well.
Here is the code:
var
Number:string;
NewNumber:string;
prefix:string;
begin
Number:=copy(Filename,15,2);
prefix:=copy(Filename,1,14);
NewNumber:=Inttostr(StrToInt(Number)+1);
while (length(NewNumber)<2) do
begin
NewNumber:='0'+NewNumber;
end;
Filename:= prefix + NewNumber + WideExtractFileExt(FileName);
end.
Damon Deaton
Offline