Replace Portions of File Names After Certain Words

Advanced Renamer forum
#1 : 13/03-22 18:08
matthew ryan
matthew ryan
Posts: 2
I'm trying to find a way to rename files by defining starting words so that anything after those words will fall under the new naming rule. For instance:

A5-05-05A - 5th Floor Enlarged Plans and Interior Elevations - CVIR
A5-02-04 - 2nd Floor Enlarged Plans and Interior Elevations - Main ED

I would like a rule that would make it so that everything starting with and after "Enlarged" will be able to be renamed to a set phrase. In this case I'd like it to read:

A50505A 5th FLR ENLG PLNS
A50204 2ND FLR ELNG PLNS

This is due to our jurisdiction having naming rules for files uploaded to their online permit system. Some of our sets are over 100 pages and a substantial portion fall under the A5 series. Just looking to find a way to spare our younger staff the "joy" of manually renaming everything! Thanks.


13/03-22 18:08
#2 : 13/03-22 20:05
Joel de Bruijn
Joel de Bruijn
Posts: 27
Reply to #1:

With "everything starting with and after "Enlarged" " do you mean it as a filter and a replacement for the whole filename or just that part of the sentence? Because otherwise parts end up double in the filename.

If so:

Method: Replace with "Use regular expressions" on.

Text to be replaced:
(.+)-(.+)-(.+) - (.+) Floor Enlarged (.+)

Replace with:
\1\2\3 \4 FLR ENLG PLNS

Screenshot:
https://pic.li/i/DuQU


13/03-22 20:05 - edited 13/03-22 20:18
#3 : 13/03-22 22:48
David Lee
David Lee
Posts: 1125
Reply to #1:
Your request does not make sense - you have asked for a solution to replace anything starting with "Enlarged" with a "set phrase" but your examples suggest that you want to do more than this - please make up your mind exactly what you want before asking for assistance!

To achieve the result you actually asked for you simply need to...

Replace: "Enlarged*"
with: "ENLG PLNS"
(NOT a regular expression)

However this will return "A5-05-05A - 5th Floor ENLG PLNS" and "A5-02-04 - 2nd Floor ENLG PLNS"

If we follow your examples instead of your request then you can use a "List replace" method with 3 lines...

1) Replace: "Enlarged.*" with: "ENLG PLNS"
2) Replace: "Floor" with: "FLR"
3) Replace: "- ?" with <leave blank>
Use regular expressions

It should be obvious how to extend this to handle other words and phrases.

One of your examples (but not the other) suggests that you may want all upper case - if so then just add a "New case" method.

All this is basic usage of Advanced Renamer and is clearly described in the User Guide so please RTFM!

Edit: Re-reading your original post I notice that you refer to the "substantial portion" of files "fall[ing] under the A5 series". Does that mean that in addition to the above you also wish to rename only files with names commencing "A5..."? If so then you will need to use a script; try the following...

newName = item.name;
if (newName.match(/^A5/)) {
newName = newName.replace(/Enlarged.*/,"ENLG PLNS");
newName = newName.replace("Floor", "FLR");
newName = newName.toUpperCase();
}
return newName;



13/03-22 22:48 - edited 14/03-22 17:38
#4 : 20/03-22 15:57
matthew ryan
matthew ryan
Posts: 2
Reply to #2:

Thank you so much that works like a charm! I'm very new to this program and still trying to wrap my head around all the options it has.


20/03-22 15:57