How to place serial number in front?

Bulk Rename Utility How-To's

How to place serial number in front?

Postby amazing » Sat Jul 31, 2021 4:45 am

I have these file names below.

How do I rename the following from:
Code: Select all
Price Action Fundamentals-How to Trade Prerequisites-Trade Management and Taking Profits-Video 36.mkv
Share Market-How to Trade Price Action-Trading Price Action Patterns How to trade-Video 37.mkv
Share Market-How to Trade Price Action-Trading Price Action Patterns-Trading MTR Tops-Video 38.mkv
Share Market-How to Trade Price Action-Trading Price Action Patterns-Trading MTR Bottoms-Video 39.mkv
ShareMarket-How to Trade Price Action-Trading Price Action Patterns Entering Late in Trends-Video 40.mkv
Share Market-How to Trade Price Action-Trading Price Action Patterns-Trading Breakouts-Video 41.mkv
How to Trade Price Action-Trading Price Action Patterns-Trading Climactic Reversals(Failed)-Video 42.mkv


to

Code: Select all
36 Trade Management and Taking Profits
37 How to trade
38 Trading MTR Tops
39 Trading MTR Bottoms
...
42 Trading Climactic Reversals(Failed)

amazing
 
Posts: 12
Joined: Sat Jul 31, 2021 4:38 am

Re: How to place serial number in front?

Postby Luuk » Sat Jul 31, 2021 7:10 am

This depends on your rule for 37 How to trade when theres not a hyphen.. So when theres not a hyphen, there can be many rules like...
Maximum of 3 words?? Start after words like (Patterns|Prerequisites)?? Start with the very last word like (How|Which|When|*ing)??
Until deciding for the rules, you can use the RegEx(1) with a 'Match' and 'Replace' like...
^.*-([^-]+)-Video (\d+)
\2 \1

This can preserve more of the string until deciding for the rules, and also Extensions(11) can remove the extensions.
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm

Re: How to place serial number in front?

Postby amazing » Sun Aug 01, 2021 6:39 am

thanks for the reply!

Do you mind explaining the regex portion, especially what each character does? I tried to modify it to allow for alphabets from the numbers (48A...48B etc, see screenshot) but it doesn't work.


For 37, perhaps the pattern can be the words in between 2 hyphens?
https://i.imgur.com/6FOQlgI.png
amazing
 
Posts: 12
Joined: Sat Jul 31, 2021 4:38 am

How to place "ending numbers and maybe 1-uppercase" in front

Postby Luuk » Sun Aug 01, 2021 3:03 pm

To also match and move one uppercase alphabet with the numbers, can change the 'Match' like...
.+-([^-]+)-Video (\d+[A-Z]?)$
\2 \1

.+- matches one-or-more characters until - (matching as much as possible).
Since not inside of parenthesis, this text cannot be part of the new name.

([^-]+) matches one-or-more characters, but these characters can not be -.
Since inside of parenthesis, \1 can put this text inside for the new name.

-Video just matches the exact string "-Video "
Since not inside of parenthesis, it cannot be part of the new name.

(\d+[A-Z]?) matches one-or-more digits, then zero-or-one uppercase alphabet.
Since inside of parenthesis, \2 can put this text inside for the new name.

The $ does just verify that the names must end like the previous descriptions.
So the names cannot have any extra text, after the digits and maybe 1 uppercase.
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm

Re: How to place serial number in front?

Postby amazing » Sat Aug 07, 2021 2:02 am

Fantastic explanation!

Taking this as an example,

(\d+[A-Z]?)

If I want to have zero to 3 upper OR lowercase alphabets, and I want to capitalize this alphabet regardless, how should it be written?
amazing
 
Posts: 12
Joined: Sat Jul 31, 2021 4:38 am

Re: How to place serial number in front?

Postby Luuk » Sat Aug 07, 2021 10:01 am

Instead of using shortcuts like ? or + or *, you can also just say the numbers like {minimum,maximum}.
Except that when you want to say or-more, you just leave out maximum, so this some different ways to say the numbers...

For 1-or-more, you can say it like + or {1,}
For 0-or-more, you can say it like * or {0,}
For 0-or-one,,, you can say it like ? or {0,1}
For 0-to-3, you say it like............... {0,3}
For 11, you say it like................... {11}

To match both lowercase and uppercase english letters, it can either be like... [A-Za-z] or (?i)[A-Z].
To also match many other word characters besides just a-thru-z, it can be like... \w.
Except just add {0,3} afterwards to match anywhere from 0-3 of your letters.

To captalize text inside of the replacement, first to put a checkmark inside for the "v2" option.
This does grant using \U to start capitalizing, and also \E to stop the capitalizing.
So for your example, Im thinking you probably want a 'Match' and 'Replace' like...

.+-([^-]+)-Video (\d+[A-Za-z]{0,3})$
\U\2\E \1

Use very careful previews if changing [A-Za-z] into \w, because BRU's regex has a problem case-converting some unicodes!
viewtopic.php?f=12&t=5421&start=0#p14639
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To