# Duplicated text removal from filename and title

**URL:** <https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394>\
**Category:** Support\
**Created:** [October 13, 2023, 9:52am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394 "2023-10-13T09:52:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 9:52am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/1 "2023-10-13T09:52:04Z")

</div>

Hello there, I've got a lot of albums to fix. One of them is duplicated artists.

Current:

01 This Is What You Came For (Calvin Harris feat. Rihanna) (Calvin Harris feat. Rihanna).mp3

Need:

01 This Is What You Came For (Calvin Harris feat. Rihanna).mp3

Is there a regex that can check for text duplicates from the file extension backwards and remove one of the duplicates found from the filename and title?

Remove " (Calvin Harris feat. Rihanna)"

I need to avoid it removing any other content in brackets, which isn't duplicated (like "(EP)" or "(Acoustic)" for example). The album artist, artist and album are all "Now That's What I Call Music!", so can't just reset from other tags.

It will always be (ARTIST) (DUPLICATE).mp3 that needs changing to (ARTIST).mp3.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 10:12am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/2 "2023-10-13T10:12:17Z")

</div>

You could filter for `) (` in a filename and then remove 1 pair of brackets.  
and if this is a problem of the album

> [@sheepdisease](#):
>
> Now That's What I Call Music!

then I would use that also as filter criterion.

You can then use Convert\>Filename-Filename to streamline the filename.

> [@sheepdisease](#):
>
> The album artist, artist and album are all "Now That's What I Call Music!", so can't just reset from other tags.

This may be an example why the initial choice to put structured data from fields into an unstructured string has its drawbacks, esp. if this information is not separated from the rest of the data by a uniqe separator. And brackets are usually not unique. Better choices are chevrons, curvy brackets, underscores.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [October 13, 2023, 10:20am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/3 "2023-10-13T10:20:42Z")

</div>

> [@sheepdisease](#):
>
> The album artist, artist and album are all "Now That's What I Call Music!",

If you have to change it for one album only, I would just filter for "Now That's What I Call Music!" and then change these TITLE manually. You need about 5 Minutes in Mp3tag to check for duplicated text visually and change/fix 20 tracks.

If you need to change many more albums, I would have a look if online sources like MusicBrainz or Discogs could help you to fix all your wrong ALBUM, ARTIST, ALBUMARTIST content.  
For example MB lists many different [series for NTWICM](https://musicbrainz.org/search?query=Now+That%27s+What+I+Call+Music%21&type=series&method=indexed).  
For example if you own the [USA version](https://musicbrainz.org/series/d223e2e2-e90b-4d88-b637-4215b7ebaac2) click on this and have a look if your specific # is available.  
WebSource Scripts can then help you to get the correct tag content.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 10:25am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/4 "2023-10-13T10:25:23Z")

</div>

Thanks both. I wanted to know if there was essentially regex that can fix the problem when it happens occasionally. If I take the data from another source, I lose some of the changes I have made like who the artist should be (then I end up with tracks being moved into individual artist folders, instead of being in one folder for each disc).

![image](https://community.mp3tag.de/uploads/default/original/2X/0/0e4c87dfabf7124b95c34765c561d779fa9ba397.png)

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 10:28am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/5 "2023-10-13T10:28:06Z")

</div>

> [@sheepdisease](#):
>
> What am I doing wrong?

You didn't look at the documentation:

> **[Rearrange Parts of File Names – Mp3tag Documentation](https://docs.mp3tag.de/converters/rearrange-filenames/)**
>
> Documentation on Filename to Filename, a converter to rearrange parts of file names. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 10:28am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/6 "2023-10-13T10:28:33Z")

</div>

Cool website though!

> **[Now That’s What I Call Music!](https://musicbrainz.org/series/4b5f2897-9b05-4799-b895-6620e27143e7)**
>
> Release group series

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 10:32am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/7 "2023-10-13T10:32:49Z")

</div>

It's a bit brief

# Rearrange Parts of File Names

Using **Convert → Filename - Filename** , you can rearrange parts of file names by marking up to nine parts using a pattern over the file name and rearrange them using a new file name pattern.

The **Old filename pattern** splits the file name in several parts. It is built of standard text (e.g., `Music` and delimiters like `-`, `_`) and by placeholders that denote the reusable parts, starting at `%1`, `%2`, up to `%9`.  
You can mark directories via the backslash character `\` within the pattern string.

The **New filename pattern** uses the previously defined parts (accompanied by optional standard text) to resemble the target file name.

If you use the backslash character `\` within the new filename pattern, Mp3tag creates new directories below the current working directory for relative paths or at the at an absolute folder location if it starts with a drive specification, e.g., `D:\Music`.

You can use [Scripting Functions](https://docs.mp3tag.de/scripting) when defining the new filename, e.g., `$upper(%1)`.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 10:42am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/8 "2023-10-13T10:42:42Z")

</div>

As the function also has a preview, I do not think that it would be too much of a trouble to at least try it and then, if you really cannot make any sense of it, show us your attempts so that we can build on it.

So far I cannot not add anything more to the - what you call "brief" - 165 words as this is about the description that I also would have thought of.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 11:11am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/9 "2023-10-13T11:11:25Z")

</div>

> [@sheepdisease](#):
>
> ![image](https://community.mp3tag.de/uploads/default/original/2X/0/0e4c87dfabf7124b95c34765c561d779fa9ba397.png)

I did already try and it didn't provide a preview as I am clearly doing something wrong and don't understand from the documentation what that is. I'd really need an example to understand.

![image](https://community.mp3tag.de/uploads/default/original/2X/0/0e4c87dfabf7124b95c34765c561d779fa9ba397.png)

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [October 13, 2023, 11:13am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/10 "2023-10-13T11:13:58Z")

</div>

> [@sheepdisease](#):
>
> The **Old filename pattern** splits the file name in several parts. It is built of standard text (e.g., `Music` and delimiters like `-`, `_`) and by placeholders that denote the reusable parts, starting at `%1`, `%2`, up to `%9`

Where do you use this placeholders `%1`, `%2` up to `%9` in your filename patterns?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 11:15am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/11 "2023-10-13T11:15:09Z")

</div>

> [@sheepdisease](#):
>
> and by placeholders that denote the reusable parts, starting at `%1`, `%2`, up to `%9`.

I am missing the %1, %2 etc. in your attempt.  
Please note that it does not say anything about field variables in the whole description of the function.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 11:19am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/12 "2023-10-13T11:19:57Z")

</div>

Awesome, thanks!

![image](https://community.mp3tag.de/uploads/default/original/2X/7/7c8cb97104153b0ce13d0f8556768e11d25482d1.png)

Is there a way to make this an action?

```auto
%1 %2 (%3) (%4)
%1 %2 (%3)

```

 ![image](https://community.mp3tag.de/uploads/default/original/2X/b/b482e137aaa6ff8ab5aea1e49a2a85acdce319e2.png)

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 11:27am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/13 "2023-10-13T11:27:03Z")

</div>

> [@sheepdisease](#):
>
> Is there a way to make this an action?

How often in the life of a filename will this procedure be necessary?  
With regard to the unwanted duplication of the ARTIST data (which looks like a filename with the preferred data got treated again) I think that the converter gives more control as you can see the result immediately.

Perhaps a search of the forum for a routine that removes a second pair of brackets helps.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 11:29am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/14 "2023-10-13T11:29:53Z")

</div>

Based on your reply, I understand that whilst it worked in the example, it wouldn't always work as expected.

My concern with that is as outlined in my original post, a second pair of brackets may contain other text. I only want it to remove anything duplicated. If the subsequent brackets contained anything else, I wouldn't want them to be removed.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [October 13, 2023, 11:32am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/15 "2023-10-13T11:32:36Z")

</div>

> [@sheepdisease](#):
>
> My concern with that is as outlined in my original post, a second pair of brackets may contain other text. I only want it to remove anything duplicated. If the subsequent brackets contained anything else, I wouldn't want them to be removed.

That's exactly why you should use the Converter and check the Preview if you really get what you want.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 11:34am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/16 "2023-10-13T11:34:25Z")

</div>

> [@sheepdisease](#):
>
> it wouldn't always work as expected

Exactly - but mainily due to too little overview of the real data: the GIGO principle cannot be overruled.  
The function itself works excatly as set - it is only the treated data that does not always match the assumption.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 13, 2023, 11:37am UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/17 "2023-10-13T11:37:58Z")

</div>

This is an example of why I wanted something that checks from right to left, starting at the end:

03 This Girl (Kungs Vs. Cookin' On 3 Burners) (Kungs) (Kungs)

03 This Girl (Kungs Vs. Cookin' On 3 Burners) (Kungs)

It's not possible?

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [October 13, 2023, 12:09pm UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/18 "2023-10-13T12:09:13Z")

</div>

Feel free to find a working regular expression. No one can say for sure if it it's possible or not. Because it highly depends on your data.

**BTW:**  
Your song should be named with one of this two variants:

 ![image](https://community.mp3tag.de/uploads/default/original/2X/6/6b6fe6284b1758a3c8cbac11dec2498e110809c3.png)  
The song TITLE is just called "This Girl".  
This one is remixed by ARTIST "Kungs".  
The original song was made by "Cookin' on 3 Burners".  
There is no need to repeat (Kungs) once or twice in brackets.

[Additional info:](https://en.wikipedia.org/wiki/This_Girl_(Cookin%27_on_3_Burners_song))  
"This Girl" is a song by Australian funk trio "Cookin' on 3 Burners" from 2009.  
French DJ "Kungs" remixed and released the above track 2016.  
He made 3 more remixes called "Extended Mix", "Fabich Remix" and "Betical Remix".

It depends on your current naming scheme how you want to rename all variants.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 12:38pm UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/19 "2023-10-13T12:38:30Z")

</div>

> [@sheepdisease](#):
>
> This is an example of why I wanted something that checks from right to left

What happened to the initial suggestion to filter for `) (`.  
Thenyou select files that need treatment and apply the converter. Much faster than renamng the files manually.  
you could expand the filter expression witn `AND NOT %_filename% HAS "Remix) ("`  
to leave ot these files.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 13, 2023, 2:02pm UTC](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394/20 "2023-10-13T14:02:39Z")

</div>

Try this filter:  
`"$if($eql($regexp(%title%,.*?(\(.*?\)) (\(.*\)),$1) $regexp(%title%,.*?(\(.*?\)) (\(.*\)),$2)),yes,no)" IS yes AND %title% HAS ") ("`

as you refer to TITLE also. If TITLE is not correct, replace any reference to TITLE with the correct property.

[Next page](https://community.mp3tag.de/t/duplicated-text-removal-from-filename-and-title/62394.md?page=2)
