#1 2019-01-27 16:03

Julius_Deane
Member
Registered: 2019-01-27
Posts: 1

Renaming with PARTIAL number replacement?

A more or less peculiar problem of sorts with a hobby of mine, historic data: various folders with filenames following a given naming scheme consisting of LOCATION and (PRODUCT), both of which are the same in the folder I am working on. As in 'speaking filenames': you always know from which folder the file comes should I have to create a collage.

Groupings therein are represented by a leading two-digit number. This is followed by a hyphen and a three-digit dec/binary size indicator. Finally there is a hyphen and a two digit file number.

My 'problem' is that it may happen that a certain Grouping has to be included between existing files, meaning that I have to rename all files from file [X] onward, keeping the original numbers but increased by one. So files with '19'  go '20', files with '20' go '21', files with '21' go '22', etc. ... as far as I understand one would require a temporary files table or 'top-to-bottom' rename mechanism to avoid double filenames. Can ReNamer do this? Everything I tried did not work (but then I may be plain stupid). Thanks in advance!

Example names:

LName (PName) 17-400-26.txt
LName (PName) 18-200-11.txt
LName (PName) 19-200-01.txt
LName (PName) 19-200-02.txt
LName (PName) 19-200-03.txt
LName (PName) 19-400-01.txt
LName (PName) 19-400-02.txt
LName (PName) 19-400-03.txt
LName (PName) 19-400-04.txt
LName (PName) 19-400-05.txt
LName (PName) 19-400-06.txt
LName (PName) 19-400-07.txt
LName (PName) 19-400-08.txt
LName (PName) 19-400-09.txt
LName (PName) 20-200-01.txt
LName (PName) 20-200-02.txt
LName (PName) 20-400-01.txt
LName (PName) 20-400-02.txt
LName (PName) 20-400-03.txt
LName (PName) 21-400-01.txt
LName (PName) 22-400-01.txt
LName (PName) 23-400-01.txt
LName (PName) 24-200-01.txt

Offline

#2 2019-01-27 22:09

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

Re: Renaming with PARTIAL number replacement?

Hi and welcome!

If you want you can check out a PascalScript to accomplish what you want.


FROM:
LName (PName) 19-200-01.txt
LName (PName) 20-400-03.txt
LName (PName) 21-400-01.txt
LName (PName) 22-400-01.txt
LName (PName) 23-400-01.txt
LName (PName) 24-200-01.txt

TO (add '3' to first found number):
LName (PName) 22-200-01#.txt
LName (PName) 23-400-03#.txt
LName (PName) 24-400-01#.txt
LName (PName) 25-400-01#.txt
LName (PName) 26-400-01#.txt
LName (PName) 27-200-01#.txt


USE:
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):
//     LName (PName) 19-200-01.txt
strRE := '^(.+ )(\d\d)(-\d\d\d-\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 := 3;

////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 := 0;

////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, [b]remove that afterwards your self[/b] 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



 


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

Board footer

Powered by FluxBB