Rename part IF

Bulk Rename Utility How-To's

Rename part IF

Postby KasparsK » Wed Aug 07, 2024 1:25 pm

Hi,
I'm new to Bulk Rename Utility but it looks quite powerful tool!
Quite sure it has almost endless possibilities regarding renaming.
So, that's why I'm asking -
The task is to rename symbol in file name witch is separated by specific characters to another symbol if some statement in file name is TRUE.
Is that possible? For example-

The original file names are-

001_AR_0_IN72-02-revA
002_AR_0_IN72-01-revB
003_AR_0_IN71-02-revC
004_AR_0_IN73-01

The task is to rename files like this-

001_AR_1_IN72-02-revA
002_AR_2_IN72-01-revB
003_AR_3_IN71-02-revC
004_AR_0_IN73-01

So,
only if in the file name exists "revA" then replace "_0_" with "_1_"
only if in the file name exists "revB" then replace "_0_" with "_2_"
only if in the file name exists "revC" then replace "_0_" with "_3_"
otherwise dont do nothing

Hope explained +- understandably.

Thanks in advance!

Kaspars
KasparsK
 
Posts: 4
Joined: Wed Aug 07, 2024 1:08 pm

Replace _digit_ if name ends with revision

Postby Luuk » Wed Aug 07, 2024 4:40 pm

With Replace(3) having the checkmark for Match Case, the "Replace" and "With" can be like...
_0_*revA|_0_*revB|_0_*revC
_1_*revA|_2_*revB|_3_*revC

If names must end with a revision?, can put \end\ at the very beginning of your "Replace".
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Rename part IF

Postby KasparsK » Thu Aug 08, 2024 6:15 am

Thanks for reply!

Unfortunately nothing happens when I insert Your formula..
Image

Kaspars
KasparsK
 
Posts: 4
Joined: Wed Aug 07, 2024 1:08 pm

Replace _0_ if name ends with revision

Postby Luuk » Thu Aug 08, 2024 3:00 pm

The Replace(3) example using * requires the latest BRU-version... http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=1&t=6600
For older versions, RegEx(1) would need the "v2" checkmark, with a "Match" and "Replace" something like...
_0_(?=.+-revA$)(?X)_0_(?=.+-revB$)(?X)_0_(?=.+-revC$)
_1_(?X)_2_(?X)_3_

If revisions arent always at the very end, can remove $ from the (look-aheads).
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Rename part IF

Postby KasparsK » Thu Aug 08, 2024 3:52 pm

Thats awesome! It worked! Thanks a lot!

And now I am tempted to go further:)

My workflow was kinda like this
1) at first step from file names, for example:

LOC_SS_7.1_IN71-revA_Drawing name
LOC_SS_7.1_IN42-revC_Drawing name
......

i got this:

001_IN_0_Drawing name_IN71-revA
002_IN_0_Drawing name_IN42-revC
......
Image

2) Then to change "_0_", I loaded renamed files again and got output like this :

001_IN_1_Drawing name_IN71-revA
001_IN_3_Drawing name_IN42-revC
......
Image

this result is satisfying me absolutely.
I am just curious, would it be possible to do those 2 steps altogether in one step somehow?

Kaspars
KasparsK
 
Posts: 4
Joined: Wed Aug 07, 2024 1:08 pm

Insert _Digit_ based on revision-character

Postby Luuk » Thu Aug 08, 2024 8:44 pm

With RegEx(1), the "Match" and "Replace" could be more like...
.+(_IN\d+(?:-\d+)?(?:-rev[A-Z])?)(_.+)
_IN_:\2\1:

Then Replace(3) having a "Replace" and "With" more like...
:*A:|:*B:|:*C:|:*D:|......|:*:
1*A|2*B|3*C|4*D|......|0*
The last-replacement must stay at the very end, to insert 0 for names without any revision.

Then Numbering(10) wont need separators, so all 3-settings to rename like...
LOC_SS_7.1_IN71-07-revB_Drawing name ----> 001_IN_2_Drawing name_IN71-07-revB
LOC_SS_7.1_IN71-08_Drawing name ----------> 002_IN_0_Drawing name_IN71-08
LOC_SS_7.1_IN71-revA_Drawing name -------> 003_IN_1_Drawing name_IN71-revA
LOC_SS_7.1_IN71_Drawing name --------------> 004_IN_0_Drawing name_IN71

To put everything inside of RegEx(1), it needs the "v2" checkmark with very many (?X) to say "next-regex".
Could also put the RegEx(1) "Match" inside of your Filters(12) "Mask" (with a RegEx checkmark) if needed?
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Rename part IF

Postby KasparsK » Fri Aug 09, 2024 7:33 am

Awesome!

I must admit, I don't quite follow RegEx(1) formula, but everything works.

Thank You!

Kaspars
KasparsK
 
Posts: 4
Joined: Wed Aug 07, 2024 1:08 pm


Return to How-To