Replacing Everything after underscore with blank space

Advanced Renamer forum
#1 : 07/10-18 23:55
Lombe Chileshe
Lombe Chileshe
Posts: 4
I'm pretty new to regex and using advanced renamer, so I need some help.

Assume I had a group of files with this format of naming

firstnamesurname_54250_4263220_Animation_Project_2_firstname_surname.pde

And I only want to retain the text before the first underscore so it becomes

firstnamesurname.pde

How would I go about that?

What if I had something like this

firstnamesurname_54250_4263220_Animation_Project_2_firstname_Q2.pde
And I only wanted to keep the last part of that string so it became something like
firstname_Q2.pde How would I do something like that?

Any help will be appreciated.


07/10-18 23:55
#2 : 08/10-18 11:43
David Lee
David Lee
Posts: 59
Reply to #1:
Both problems are straightforward but you do need to use regular expressions - see Kim's introduction at www.advancedrenamer.com/user_guide/regular_expresions.

Basically the procedure is to break the filename into two subpatterns and select the appropriate one as the Replace string.

Use the Replace method applied to Name in both cases and tick the "Use regular expressions" box.

In the first case use the regular expression (.+?)(_.+) and Replace with: \1 (which is the first subpattern - ie "(.+?)" ). The trick here is the inclusion of the question mark - without it the filename will be split at the final underscore rather than the first.

For the second case use RegEx (.+_)(.+_.+$) and Replace with: \2.

Regular Expressions can be bewildering when you first encounter them but are really straightforward once you know what you are doing. Kim's introduction is very good and it's helpful to look at https://en.wikipedia.org/wiki/Regular_expression as well.


08/10-18 11:43 - edited 09/10-18 10:05
#3 : 10/10-18 04:47
Lombe Chileshe
Lombe Chileshe
Posts: 4
Reply to #2:
Thank you. I'll read further about regular expressions


10/10-18 04:47
#4 : 10/10-18 05:27
Lombe Chileshe
Lombe Chileshe
Posts: 4
Reply to #2:
The replace with method isn't working for me for some reason. This is what I get when I enter the patterns you gave me.

https://imgur.com/a/UOxfR9E


10/10-18 05:27
#5 : 10/10-18 05:41
Lombe Chileshe
Lombe Chileshe
Posts: 4
Reply to #2:
Oh my bad. I get it now. I misunderstood the instruction. Never mind


10/10-18 05:41