Rename only once per file

Advanced Renamer forum
#1 : 09/04-21 10:33
Suter
Suter
Posts: 3
Hello
I created a with a new rename-method that adds a prefix (according to the folder name) and a suffix (change date). Now I'd like to create a batch job that renames all my files (including all subfolders) according to my rename-method, but in this job all files that contain already the proper prefix an suffix should be exluded. Until now, everytime I start the job, the new prefix and suffix ist added one more time.
What would be the right command line to exclude these files?


09/04-21 10:33
#2 : 09/04-21 13:02
David Lee
David Lee
Posts: 1125
Post details of your rename method and examples of typical filenames.


09/04-21 13:02
#3 : 09/04-21 15:11
Suter
Suter
Posts: 3
Reply to #2:
This is the method I wrote:
[methods]
method0000=methodname:"add"; active:"1"; position:"0"; add:"<DirName:-5>_"; backwards:"0"; applyto:"name"; regularexpressions:"0";
method0001=methodname:"add"; active:"1"; position:"0"; add:"_<Year Modified><Month Modified><Day Modified>"; backwards:"1"; applyto:"name"; regularexpressions:"0";

And a typical original file name could be: Route overview
and the path: D:\Dropboxe\Private\Climbing\Mont Blanc

So in this example the file is named after the method: Mont Blanc_Route overview_20210409

The goal is that the job "recognizes" the renamed files and only new files for example "Climbing day 1" are renamed. Otherwise my original file "Route overview" would be called: Mont Blanc_Mont Blanc_Route overview_20210409_20210409 after the second run of the job and so on.
This way I can use easy original file names and the Advanced Renamer adds important infos.


09/04-21 15:11
#4 : 09/04-21 17:16
David Lee
David Lee
Posts: 1125
Reply to #3:
First a couple of comments on your batch...

1) You can simply use the tag <DirName> (ie without specifying the level) to return the name of the sub-folder immediately containing each file.

2) You can achieve the same result with a single Replace method, thus...
Text to be replaced: (.*)
Replace with: <DirName>_\1_<Year Modified><Month Modified><Day Modified>

In order to test for previously renamed files you will need to translate the second form into a script...

name = item.name;
prefix = app.parseTags("<DirName>");
test = name.match(/[^_]*/);
if (test != prefix) {
return prefix + "_" + name + app.parseTags("_<Year Modified><Month Modified><Day Modified>");
}

Here I am only testing for the presence of the prefix (ie folder name).


09/04-21 17:16
#5 : 12/04-21 08:28
Suter
Suter
Posts: 3
Reply to #4:
Hello David

Thansk a lot. Your skript works perfectly :-)

Best regards
Suter


12/04-21 08:28