Help with Reg Ex / action

If a title contains the string [Previously Unreleased how do I replace the title with what's to the left of [Previously Unreleased? I'm selecting about 100 tracks, so the action needs to work with titles that don't contain that string (i.e. no action)

Cheers

Hi there.

I think it will work:
Action: Replace with regular expression
Field: TITLE
Regular expression: (.*?)([Previously\sUnreleased)
Replace matches with: $1

Thanks. I'll try and work it out, but

Everybody's Alone [Previously Unreleased Song] [Previously Unreleased Song]/Previously Unreleased Song

became

Everybody's Alone Song] Song]/Previously Unreleased Song

So you did not write your problem properly. The script does what you asked for, you have other problems here, what is it then, a title can randomly have the text "Previously Unreleased Song" for a random number of times with or without brackets and a / char?? LOL that is weird.

Read your first opening comment again and try to fix it so that everybody understands it.

I would like
Everybody's Alone [Previously Unreleased Song] [Previously Unreleased Song]/Previously Unreleased Song
to become
Everybody's Alone

but
ABCD [ Live at the Ally Pally]
to stay as it is

and XYZ with no other ['s in the title to stay as XYZ too

Thank you

OK. If ALL your problematic tracks start with "[Previously".... then this wil remove everything after it:
(.?)([Previously.?)
Replace matches with: $1

Sadly, this was similar behaviour to before
Everybody's Alone [Previously Unreleased Song] [Previously Unreleased Song]/Previously Unreleased Song
became
Everybody's Alone Unreleased Song] Unreleased Song]/Previously Unreleased Song

I had a look at some examples, e.g. TagsLikeThese and agree with the principle, but I guess because there are multiple occurrences of the same string, this is throwing it

I have got around this now by doing it manually with a normal text replace, which is sufficient thank you

Actually there's 100's of variations of these and it's a pain going through all the variants. I am going to start a new thread if that's ok, as I think it's a filename length problem that I am creating with a tag -> filename conversion

It was my bad, I overlooked something, I fiexed it now. I shouldn't have used the "?", simply remove the last question mark. But the script below will remove any extra spaces too so the new title will end properly.

Regexp:
(.?)(\s)([Previously.*)
Replace with: $1

So.. it works with any title that has the junk at the end starting with "[Previously" and removes everything else to its right.
Tested it with many examples, if it still doesn't work, let me know.

I'm no expert myself either, but I thought it's useful to try and help you, even though it took me 3 tries.

Thanks a million - I appreciate mate. I do have unix experience, but sed / grep / awk were never my forte, and I was curious about the ? too, which was throwing me a bit

I'm not 100% sure of the difference between these
(.?)(\s) and
(.)(\s)

I did try having a look at your DJ Hidden query, but until I understood this one (which I have only just loaded) I wouldn't have a chance.

Thanks once again

No prolem mate.

About the question mark:
Every symbol or special character has a property called being "greedy" which means they do not stop at the very first occurrence of the character to its right but matches the last possible one.

So in this example (.)(\s)
Here we look for two characters, any character+a space.
But that can happen multiple times throughout the text, so it will not stop at the first place it occurs.
To force it to stop at the very first occurrence of "any character+space", use "?" after the "any character".

Thus the (.?)(\s)

Brilliant explanation

Cheers

You're welcome - I learn as I go through these as well :wink: