# Extract part of Filename and Compare To Title

**URL:** https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235
**Category:** Support
**Created:** [January 22, 2025, 3:18am UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235 "2025-01-22T03:18:30Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![spinner410](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@spinner410](https://community.mp3tag.de/u/spinner410)
#### Post date: [January 22, 2025, 3:18am UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/1 "2025-01-22T03:18:30Z")

</div>

Hi there: I want to extract part of the filename and compare that value to the value in the Title field.

Basically, I want to compare everything after the first hyphen and before the file extension to the value in the Title field.

An example of my file name is:

Artist Name - Song Title.mp3

Mind you I want to be able to compare whatever comes after the hyphen and before the file extension even if it doesn't exactly match the example above.

Thanks!

---

<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: [January 22, 2025, 6:59am UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/2 "2025-01-22T06:59:28Z")

</div>

What exactly do you want to do with `Song Title` in your example?  
If you don't already have `Song Title` in the `TITLE` field, what do you want to do?  
Replace the current content? Append it to the current content?

Or do you want to create a new custom column to visually compare it with TITLE?

---

<div class="post-metadata">

### Author: ![spinner410](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@spinner410](https://community.mp3tag.de/u/spinner410)
#### Post date: [January 22, 2025, 12:49pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/3 "2025-01-22T12:49:40Z")

</div>

I want to make sure the values match and if they don't I want to see which songs have unmatched values.

---

<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: [January 22, 2025, 1:11pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/4 "2025-01-22T13:11:45Z")

</div>

You could apply a filter  
`"$ifgreater($strstr($lower(%_filename%),$lower(%title%)),0,1,0)" IS "0"`

You still have to check the files as variation could appear due to characters that are OK in a TITLE but are invalid in a filename.

If you want to get a column, enter as  
Value: `$ifgreater($strstr($lower(%_filename%),$lower(%title%)),0,Same,Differs)`

---

<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: [January 22, 2025, 1:18pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/5 "2025-01-22T13:18:07Z")

</div>

Or you could [add an new custom column](https://docs.mp3tag.de/customization/file-list/#adding-and-removing-columns).  
As name you can choose whatever you want.  
As **Value** use  
`$if($strcmp($regexp(%_FILENAME%,.*?- (.*),$1),%TITLE%),yes,no)`

 ![image](https://community.mp3tag.de/uploads/default/original/3X/1/d/1dcda20e0ea3930dff04414611ecb6ffac02579f.png)

```auto
$strcmp(x,y) compares strings x and y case-sensitively
$stricmp(x,y) compares strings x and y case-INsensitively

```

This would look like this in Mp3tag:

 ![image](https://community.mp3tag.de/uploads/default/original/3X/f/3/f35d13a002f1ce92319f1c2a93e0ddb8a9463548.png)

As always if you use regular expressions: They only work for the given example.  
In your case with some text in front of a space and a hyphen and a space and some other text that will be compared with the content of TITLE.

---

<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: [January 22, 2025, 1:34pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/6 "2025-01-22T13:34:25Z")

</div>

> [@ohrenkino](#):
>
> You still have to check the files as variation could appear due to characters that are OK in a TITLE but are invalid in a filename.

👍  
In particular, characters such as : (colon) and ? (question mark), which frequently occur in TITLEs but are invalid in Windows filenames.  
And some more:

```auto
< (less than)
> (greater than)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
* (asterisk)

```

---

<div class="post-metadata">

### Author: ![spinner410](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@spinner410](https://community.mp3tag.de/u/spinner410)
#### Post date: [January 22, 2025, 5:54pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/7 "2025-01-22T17:54:29Z")

</div>

> [@ohrenkino](#):
>
> `"$ifgreater($strstr($lower(%_filename%),$lower(%title%)),0,1,0)" IS "0"`

thank you this worked perfectly for my purposes. thanks again!

---

<div class="post-metadata">

### Author: ![spinner410](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@spinner410](https://community.mp3tag.de/u/spinner410)
#### Post date: [January 22, 2025, 5:54pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/8 "2025-01-22T17:54:46Z")

</div>

thank you! this also worked for me - i appreciate the help!

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 21, 2025, 5:55pm UTC](https://community.mp3tag.de/t/extract-part-of-filename-and-compare-to-title/67235/9 "2025-02-21T17:55:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
