Simple request I hope

A swapping-ground for Regular Expression syntax

Simple request I hope

Postby DJ-Texas » Thu May 25, 2023 6:54 pm

All,

I need to edit various music file names (2000+). The previous software has produced filenames like the following:

Beatles - Hard Day's Night.mp3
Beatles - Lovely Rita.mp3

and many more that start with "Beatles"

How to..

1) Delete "Beatles - "

Or even better

2) Move " - Beatles" to end of filename (not into extension)
DJ-Texas
 
Posts: 5
Joined: Thu May 25, 2023 6:47 pm

Moving or removing groups of text

Postby Luuk » Thu May 25, 2023 8:12 pm

First to verify there's NOT any checkmark for "Renaming Options, File/Folder Extensions, Rename File Extensions".
Then can use a "Match" and "Replace" something like...
^(Beatles)( - )(.+)
\3\2\1

This to rename like...
Beatles - Hard Day's Night ----> Hard Day's Night - Beatles
Beatles - Lovely Rita ----------> Lovely Rita - Beatles

If wanting to completety remove the artist prefix, can just remove "\2\1" from inside of the "Replace".
But if having many artists, its probably better using a "Match" like ^(Beatles|Artist 2|Artist 3)( - )(.+)
Luuk
 
Posts: 771
Joined: Fri Feb 21, 2020 10:58 pm

Re: Simple request I hope

Postby DJ-Texas » Thu May 25, 2023 8:20 pm

Thank you!

Will give a try asap. Currently drugged from foot surgery.
DJ-Texas
 
Posts: 5
Joined: Thu May 25, 2023 6:47 pm

Re: Simple request I hope

Postby DJ-Texas » Thu May 25, 2023 8:35 pm

OK, tried but no luck (could be the drugs :-))

Which blocks am I needing to populate?

RegEx(1) or Replace(3) ?
DJ-Texas
 
Posts: 5
Joined: Thu May 25, 2023 6:47 pm

Re: Simple request I hope

Postby therube » Thu May 25, 2023 8:44 pm

1:RegEx, enable 'Simple'
Code: Select all
Match:  %1 - %2
Replace: %2 - %1

%1, match to the left of the (-)
%2, match to the right of the (-)
& switch their positions.


That is not an end-all, but it will work with names like you've show.
Something like: AC - DC - Dirty Deeds.mp3 might throw it off.
Last edited by therube on Thu May 25, 2023 8:50 pm, edited 1 time in total.
therube
 
Posts: 1393
Joined: Mon Jan 18, 2016 6:23 pm

Re: Simple request I hope

Postby DJ-Texas » Thu May 25, 2023 8:47 pm

OK, got it working. All parameters in RegEx.
DJ-Texas
 
Posts: 5
Joined: Thu May 25, 2023 6:47 pm

Re: Simple request I hope

Postby DJ-Texas » Thu May 25, 2023 9:09 pm

Very good, thank you.


Is there any expression/wild card that will select all to the left of " - " (e.g. file name prefix) without have to enter the various artists?
DJ-Texas
 
Posts: 5
Joined: Thu May 25, 2023 6:47 pm

Moving or removing groups of text

Postby Luuk » Fri May 26, 2023 1:03 am

Therube's suggestion conducts exactly like you're asking, or can use something like...
^(.+?)( - )(.+)
\3\2\1

But either way will reverse any previous renames, so like... Song - Artist ---> Artist - Song
And they will also destroy any Songs or Artists that might have " - " like therube is saying.

I guess you can always prefix a negative-lookahead to say "Dont match 2-or-more " - " in the names...
^(?!(?:.* - ){2,})(.+?)( - )(.+)
\3\2\1

But really I think most users probably just use a Filters(12) "Mask" like !"* - * - *" for this kind of protection.
So then, they just click the blue-arrows beside "Mask" and any names with 2-or-more " - " will disappear.
Then they just remove the ! to look at any names with many " - " so then deciding how to conduct them.
Luuk
 
Posts: 771
Joined: Fri Feb 21, 2020 10:58 pm


Return to Regular Expressions