# Add composer if title matches from text file?

**URL:** https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660
**Category:** General Discussion
**Created:** [October 30, 2007, 3:52am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660 "2007-10-30T03:52:06Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ffolke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/8edcca/32.png) [@ffolke](https://community.mp3tag.de/u/ffolke)
#### Post date: [October 30, 2007, 3:52am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/1 "2007-10-30T03:52:06Z")

</div>

I'm not sure if there is a way to do this, but it would be a great feature. I'll explain:

I have a list of titles composed by a single person. (example: copied list from [wikipedia](http://en.wikipedia.org/wiki/List_of_compositions_by_Django_Reinhardt))

> [@](#):
>
> Anouman  
> Appel Indirect  
> Are you in the Mood  
> Babik  
> Belleville  
> Black and White  
> Black Night  
> Diminushing
> 
> ...

And I have several music files that do and don't match the titles

> [@](#):
>
> Aftershave  
> Babik  
> Belleville  
> Drive me Mad
> 
> ...

My goal is to add the composer name to files that match, so

If [Line from text file] = OR is contained in %title%,  
Then Add [Name of Composer] to %composer% to MATCH

If this is not remotely possible with the current release, please consider adding such a feature. I don't care if this is a several step process, it would save time if this is possible in any way.

Not to be picky or to ask too much... it would be great preferably with liberal matching- ignore case, partial match (as in "Babik" from text file will match a file with a title of "Babik [demo]").

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [October 30, 2007, 11:55am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/2 "2007-10-30T11:55:32Z")

</div>

> [@ffolke](#):
>
> ... My goal is to add the composer name to files that match ...

An idea for do-it-yourself:  
Put your list of titles into a temporary tag field TEMPLIST.  
Do a search into this field by TITLE string using scripting function $strstr(x,y), which returns the value zero (not found) or a value greater than zero (found).  
If target is found, then format COMPOSER with the name of the related composer, otherwise do nothing.  
Afterwards remove the temporary tag field TEMPLIST.

DD.20071030.1355.CET

---

<div class="post-metadata">

### Author: ![ffolke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/8edcca/32.png) [@ffolke](https://community.mp3tag.de/u/ffolke)
#### Post date: [October 30, 2007, 5:11pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/3 "2007-10-30T17:11:04Z")

</div>

This sounds like what I need but I don't follow how to accomplish this exactly. You say to do a search, you mean with a filter or do a Format Value?

I'm really lousy at scripting and have no idea what I am doing. I tried this but it returns "Django" to all files no matter what.

_Action type:_ **Format value**  
_Field:_ **COMPOSER**  
_Formatstring:_ **$ifgreater($strstr(%title%,%templist%),0,%composer%,Django)**

I should mention that templist is line by line. Do I need to separate each value in %templist% with commas instead of line breaks?

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [October 30, 2007, 9:08pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/4 "2007-10-30T21:08:14Z")

</div>

Your were so near, now try this instead:  
Because your templist is ordered line by line I recommend to use the 'carriage return' and 'linefeed' characters as special delimiters. Make sure that your templist begins and ends with an empty line.

_Action type:_ **Format value**  
_Field:_ **COMPOSER**  
_Formatstring:_ **$ifgreater($strstr(%templist%,$char(10)%TITLE%$char(13)),0,'Django',%COMPOSER%)**

DD.20071030.2308.CET

---

<div class="post-metadata">

### Author: ![ffolke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/8edcca/32.png) [@ffolke](https://community.mp3tag.de/u/ffolke)
#### Post date: [October 31, 2007, 8:56am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/5 "2007-10-31T08:56:32Z")

</div>

You are brilliant! Thanks ever so much- it's almost perfect. I also got this working for case INSENSITIVITY:

_Action type:_ **Format value**  
_Field:_ **COMPOSER**  
_Formatstring:_ **$ifgreater($strstr($lower(%templist%),$char(10)$lower(%title%)$char(13)),0,Django,%composer%)**

Now if only I could find a way that a line in %templist% of "Babik" would be counted as a match for a %title% of "Babik (Bi-Bop)" ... or templist-LINE "Nuages" is caught in title: "Nuages - Hot Club De France Quintet" ...This is the opposite of what the current action does (without delimiter). If anyone has suggestions they will be accepted with the utmost gratitude.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [October 31, 2007, 3:47pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/6 "2007-10-31T15:47:39Z")

</div>

> [@ffolke](#):
>
> ... You are brilliant! Thanks ever so much- it's almost perfect. ...

You can try to evaluate only a specific amount of chars from the left side of the strings by using $left(). Or maybe you can find out how to isolate the first 'word'?

DD.20071031.1748.CET

---

<div class="post-metadata">

### Author: ![ffolke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/8edcca/32.png) [@ffolke](https://community.mp3tag.de/u/ffolke)
#### Post date: [November 16, 2007, 8:42pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/7 "2007-11-16T20:42:36Z")

</div>

I don't know if this warrants a separate thread, but it's along the lines of what I'm trying to achieve with the previous workaround. I've got a text list of songs with the appropriate music composer beside it and I'd like to add corresponding composer tag to matching titles in files. This is a step beyond what I'm able to accomplish with the previous script.

The list looks like this:

```
    * "Lazybones" (music by Hoagy Carmichael)
    * "P.S. I Love You" (music by Gordon Jenkins)
    * "Goody Goody" (music by Matty Maineck)
    * "I'm an Old Cowhand from the Rio Grande" 
    * "Hooray for Hollywood" (music by Richard A. Whiting)
    * "Too Marvelous for Words" (music by Richard A. Whiting)

```

and I want my music files to add COMPOSER "Hoagy Carmichael" if TITLE is "Lazybones"

Making a templist like I've been doing can match titles, but it won't output the (music by unique COMPOSER).

On a side note, it'd be great if there is a database or some script that could add composer to songs. All I know of is allmusic which sometimes lists composer, and wikipedia will list writers of songs on most albums.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 17, 2007, 8:32am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/8 "2007-11-17T08:32:59Z")

</div>

Detailed step by step action group:

Action #1:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TITLE**  
_Formatstring:_ **%TITLE%**

Action #2:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TITLE**  
_Formatstring:_ **$char(34)%FFOLKE\_TITLE%$char(34)**

Action #3:  
_Action type:_ **Text File Import**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **_Your Filepath_**

Action #4:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$replace(%FFOLKE\_TEXT\_IMPORT%,' \* ',)**

Action #5:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$replace(%FFOLKE\_TEXT\_IMPORT%,''$char(40)'music by ',)**

Action #6:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$replace(%FFOLKE\_TEXT\_IMPORT%,$char(41)$char(13),$char(13))**

Action #7:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$replace(%FFOLKE\_TEXT\_IMPORT%,$char(32)$char(13),$char(13))**

Action #8:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_POS**  
_Formatstring:_ **$strstr(%FFOLKE\_TEXT\_IMPORT%,%FFOLKE\_TITLE%)**

Action #9:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_LEN**  
_Formatstring:_ **$sub($len(%FFOLKE\_TEXT\_IMPORT%),$sub(%FFOLKE\_POS%,1))**

Action #10:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$right(%FFOLKE\_TEXT\_IMPORT%,%FFOLKE\_LEN%)**

Action #11:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_POS**  
_Formatstring:_ **$strstr(%FFOLKE\_TEXT\_IMPORT%,$char(13))**

Action #12:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_LEN**  
_Formatstring:_ **$sub(%FFOLKE\_POS%,1)**

Action #13:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$left(%FFOLKE\_TEXT\_IMPORT%,%FFOLKE\_LEN%)**

Action #14:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_TEXT\_IMPORT**  
_Formatstring:_ **$replace(%FFOLKE\_TEXT\_IMPORT%,%FFOLKE\_TITLE%,)**

Action #15:  
_Action type:_ **Format value**  
_Field:_ **FFOLKE\_COMPOSER**  
_Formatstring:_ **%FFOLKE\_TEXT\_IMPORT%**

Action #16:  
_Action type:_ **Format value**  
_Field:_ **COMPOSER**  
_Formatstring:_ **%FFOLKE\_COMPOSER%**

Action #17:  
_Action type:_ **Remove fields**  
_Fields to remove (semicolon-separated):_ **FFOLKE\_TITLE;FFOLKE\_TEXT\_IMPORT;FFOLKE\_POS;FFOLKE\_LEN;FFOLKE\_COMPOSER**

DD.20071117.1033.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 22, 2007, 10:07am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/9 "2007-11-22T10:07:14Z")

</div>

Detlev, could you post the actual action file text? I'd like to try this but don't rate my chances of filling those 17 dialog boxes without error! Thanks.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 22, 2007, 4:23pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/10 "2007-11-22T16:23:17Z")

</div>

As usual you can use Copy&Paste to minimize edit errors :-), but here comes the complete ready to use mta file:  
[Test\_ffolke\_2.mta](https://community.mp3tag.de/uploads/default/original/2X/b/be4e183374c770bac62cd9709224f147f3d61101.mta) (1.41 KB)  
And the input file:  
[FFOLKE\_TEXT\_IMPORT.txt](https://community.mp3tag.de/uploads/default/original/2X/1/1fe532fbc3a94175ade4089265bb07e247fa1cf6.txt) (321 Bytes)  
I hope you are able to understand what I have done there, if not, then feel free to ask.

DD.20071122.1822.CET

[Test\_ffolke\_2.mta](https://community.mp3tag.de/uploads/default/original/2X/b/be4e183374c770bac62cd9709224f147f3d61101.mta) (1.41 KB)

[FFOLKE\_TEXT\_IMPORT.txt](https://community.mp3tag.de/uploads/default/original/2X/1/1fe532fbc3a94175ade4089265bb07e247fa1cf6.txt) (321 Bytes)

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 23, 2007, 2:56pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/11 "2007-11-23T14:56:53Z")

</div>

Here comes a more generic version of a lookup action:

mta file: [Lookup.mta](https://community.mp3tag.de/uploads/default/original/2X/3/3b8dc6278e3ff8e3ed3f311a564ec45fc8ebccdc.mta) (794 Bytes)  
sample input file: [Lookup.txt](https://community.mp3tag.de/uploads/default/original/2X/2/289a7c24442bebe1d4a7f841c39d5e91b628592f.txt) (215 Bytes)

The input file must be a normal text file of following format (first and last line empty, unique entries):

```
@CR@LF
Lazybones|Hoagy Carmichael@CR@LF
P.S. I Love You|Gordon Jenkins@CR@LF
Goody Goody|Matty Maineck@CR@LF
I'm an Old Cowhand from the Rio Grande|@CR@LF
Hooray for Hollywood|Richard A. Whiting@CR@LF
Too Marvelous for Words|Richard A. Whiting@CR@LF

```

"@CR@LF" stands for the unvisible CarriageReturn-LineFeed sequence at end of each line of text.

This is the lookup table.  
The pipe symbol "|" is used as a delimiter between the two columns "search item|result item".  
@CR = $char(13), @LF = $char(10), | = $char(124)

Changing the view a little bit our lookup table looks like:

```
@CR
@LFLazybones|Hoagy Carmichael@CR
@LFP.S. I Love You|Gordon Jenkins@CR
@LFGoody Goody|Matty Maineck@CR
@LFI'm an Old Cowhand from the Rio Grande|@CR
@LFHooray for Hollywood|Richard A. Whiting@CR
@LFToo Marvelous for Words|Richard A. Whiting@CR
@LF

```

Each row opens with the @LF symbol as the begin-of-row marker and closes with the @CR symbol as the end-of-row marker.

Finding a title is easy, just search for a string of "$char(10)%TITLE%$char(124)"  
Additional scripting returns the corresponding string from the result column.

DD.20071123.1656.CET

[Lookup.txt](https://community.mp3tag.de/uploads/default/original/2X/2/289a7c24442bebe1d4a7f841c39d5e91b628592f.txt) (215 Bytes)

[Lookup.mta](https://community.mp3tag.de/uploads/default/original/2X/3/3b8dc6278e3ff8e3ed3f311a564ec45fc8ebccdc.mta) (794 Bytes)

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 25, 2007, 4:07pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/12 "2007-11-25T16:07:19Z")

</div>

> Or maybe you can find out how to isolate the first 'word'?

$regexp(%title%, .\*,$1) works here.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 25, 2007, 10:37pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/13 "2007-11-25T22:37:14Z")

</div>

Thanks for that Detlev. I think it would be neat to use tab rather than | at the separater. Also, perhaps rather than require the input file to have a blank line, you could add it with an action.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 26, 2007, 6:48am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/14 "2007-11-26T06:48:23Z")

</div>

> [@chrisjj](#):
>
> Thanks for that Detlev. I think it would be neat to use tab rather than | at the separater. ...

Well, I do like to use the "|" character as a delimiter symbol more than a TAB character, because it is better visuable, often TAB and SPACE are mixed up.  
You may use any other delimiter character that is unique to the lookup data.

> [@chrisjj](#):
>
> ... Also, perhaps rather than require the input file to have a blank line, you could add it with an action.

Yes, Chris, I thought too short, your suggestion is good!  
At the end it is a question of the runtime, because the actiongroup runs against each track file. Adding a CRLF before and perhaps behind a large lookup file will slow down the process for many track files entirely, therefore you can prepare the lookup file to make the process a little bit quicker. This should be evaluated by experiment.

DD.20071126.0847.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 26, 2007, 9:32am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/15 "2007-11-26T09:32:17Z")

</div>

Detlev

> Adding a CRLF before and perhaps behind a large lookup  
> file will slow down the process for many track files entirely

Yes, indeed. Writing and a big lookup file and then deleting it to hundreds of tracks could take a long time. Perhpas it would be worth Mp3tag having %actiontemp1%, %actiontemp2% and %actiontemp3% stored in memory not the file, and globally not for each track.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 26, 2007, 10:41am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/16 "2007-11-26T10:41:15Z")

</div>

Hmm, I'm not sure how the tag manipulating process works when an action runs against a track file.

1. Is it a physical process that alters the content of the track file each time when a single action is done?
2. Is it a virtual process that does all actions of an actiongroup in memory and at last writes the altered tag container completely back to trackfile?

The second method gives the chance for having a good runtime speed in relation to CPU speed and available RAM. And we could create a nearly full automatical lookup actiongroup saving the user from prepending/appending manually a CRLF to the lookup file.

Maybe Florian can post a statement regarding the action featured manipulating process of tag fields or tag field container.

DD.20071126.1239.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 26, 2007, 11:46am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/17 "2007-11-26T11:46:44Z")

</div>

Good question. I was only assuming that it was a physical process, since regular tag updates are very physical - on a single mp3 tag write, Mp3tag does six file open operations.

> Is it a virtual process that does all actions of an actiongroup in memory and at last writes the  
> altered tag container completely back to trackfile?

That would be good. Far better than my suggested %actiontemp% placeholders.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [November 27, 2007, 8:44pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/18 "2007-11-27T20:44:12Z")

</div>

> [@DetlevD](#):
>
> 1. Is it a physical process that alters the content of the track file each time when a single action is done?
> 2. Is it a virtual process that does all actions of an actiongroup in memory and at last writes the altered tag container completely back to trackfile?

Mp3tag uses the second approach. The first one wouldn't scale with many changes in the tag.

Kind regards,  
Florian

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 27, 2007, 11:09pm UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/19 "2007-11-27T23:09:29Z")

</div>

Here comes another approach, maybe tricky, maybe lower performing.

The mta file: [Lookup\_2.mta](https://community.mp3tag.de/uploads/default/original/2X/9/96fb885c8ff7025100b7a14292313f098ff3377b.mta) (781 Bytes)  
The sample input file: [Lookup\_2.txt](https://community.mp3tag.de/uploads/default/original/2X/9/9608ba98b3c3ca66d66ceac71bcaff9429967bed.txt) (211 Bytes)

DD.20071128.0110

[Lookup\_2.mta](https://community.mp3tag.de/uploads/default/original/2X/9/96fb885c8ff7025100b7a14292313f098ff3377b.mta) (781 Bytes)

[Lookup\_2.txt](https://community.mp3tag.de/uploads/default/original/2X/9/9608ba98b3c3ca66d66ceac71bcaff9429967bed.txt) (211 Bytes)

---

<div class="post-metadata">

### Author: ![chtchan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/bbce88/32.png) [@chtchan](https://community.mp3tag.de/u/chtchan)
#### Post date: [December 19, 2007, 5:44am UTC](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660/20 "2007-12-19T05:44:06Z")

</div>

Is it possible to make it match with 2 items in tag and if it matches add the third item into tag?

[Next page](https://community.mp3tag.de/t/add-composer-if-title-matches-from-text-file/5660.md?page=2)
