# Apostrophe's in Action Items

**URL:** https://community.mp3tag.de/t/apostrophes-in-action-items/18049
**Category:** Support
**Created:** [June 19, 2016, 11:13pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049 "2016-06-19T23:13:06Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [June 19, 2016, 11:13pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/1 "2016-06-19T23:13:06Z")

</div>

In action groups the apostrophe behavior is not as expected.

Logically $if(%composer%,%composer%,'') should keep composer if it exists and leave it blank if it does not exist (I know, dumb example, but it's simple). Instead if the target is blank I end up with a single apostrophe (') as the result of this statement.

Yes I know I can do $if(%composer%,%composer%,) but that's not the point.

I generate my action groups programmatically and having this result for apostrophe's makes life difficult.

So it looks like a bug to me.

k

more info, in case there's a work-around.

During tag cleanup I replace composer with an album-level composer where some albums have apostrophe's in their names (e.g., UCL - London's Global University) and others are blank. So I need a regex that can simultaneously handle both situations.  
Simply adding more apostrophes to the target of the example regex did not work.

---

<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: [June 20, 2016, 3:26am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/2 "2016-06-20T03:26:08Z")

</div>

Please see these threads on the need to escape the apostrophe and ways to do it:  
[/t/15384/1](https://community.mp3tag.de/t/15384/1)  
and a thread that you created yourself:  
[/t/16547/1](https://community.mp3tag.de/t/16547/1)

You may nest functions, e.g. $regexp($replace(...),...)

---

<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: [June 20, 2016, 6:00am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/3 "2016-06-20T06:00:44Z")

</div>

> [@](#):
>
> ... keep composer if it exists and leave it blank if it does not exist ...

This gives an unwanted result: $if(%composer%,%composer%,'')  
... because it creates one single apostrophe in case of the tagfield COMPOSER does not exist.

This is correct: $if(%composer%,%composer%,)

Note: The Mp3tag Scripting Language has no symbol for an empty string.  
You know it already ...

> [@](#):
>
> ... Yes I know I can do $if(%composer%,%composer%,) ...

You may apply the function call ... $char(0) ... to visualize an empty string within Mp3tag Scripting Language.

DD.20160620.1000.CEST

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [June 21, 2016, 12:14am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/4 "2016-06-21T00:14:19Z")

</div>

yes i was aware of my earlier posts ... hence the comment that adding additional apostrophe's doesn't help. i still think it's a bug that the mp3 scripting language doesn't have a symbol for an empty string ... but that being said do you have any ideas for a single regex that can handle the two cases I posed?

1. composer is blank OR
2. composer has a single apostrophe as integral to its name

I've tried many different combinations and permutations and haven't hit upon a solution.

K

---

<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: [June 21, 2016, 5:47am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/5 "2016-06-21T05:47:32Z")

</div>

> [@rko31415](#):
>
> ... 1) composer is blank OR  
> 2) composer has a single apostrophe as integral to its name ...

If this or that, ... what follows then ?

DD.20160621.0947.CEST

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [June 21, 2016, 11:03am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/6 "2016-06-21T11:03:48Z")

</div>

Sorry for the ambiguity. Here are two sample FORMAT statements from the ACTION GROUP. These FORMAT statements are generated using an Export Config which grabs the default composer from tiny mp3's I maintain for each album (album-level tags). This is the regex that gives me the extra single apostrophe when the default COMPOSER is blank:

REM Format Value: COMPOSER  
REM Album has default composer UCL - London's Global University

$if($eql($regexp(%album%,'',),'Lunch Hour Lectures'),  
$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U))  
,%composer%, 'UCL - London''''s Global University'), %composer%)

REM Format Value: COMPOSER  
REM Album has blank composer

$if($eql($regexp(%album%,'',),'Unbelievable¿'),  
$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U))  
,%composer%,  
''),  
%composer%)

Verbal explanation: for each album, if the composer exists and it's not 'podcast' or 'itunes u' then keep it, otherwise replace it with the album-level default composer

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [June 21, 2016, 12:14pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/7 "2016-06-21T12:14:39Z")

</div>

Sometimes just writing about an issue helps. I have solved the problem.  
Below is the Export Config that handles the situation:

$filename('C:\Documents and Settings\IDES\Application Data\Mp3tag\data\actions\Composer Fill.mta',UTF-8)'[#0]'$loop(%album%)  
'T=5'  
'F=COMPOSER'  
'1=$if($eql($regexp(%album%,'''''',),'''$regexp(%album%,'',)'''),$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U)),%composer%,'$replace(%composer%,'','''')'),%composer%)'$puts(counter,$add(1,$get(counter)))

'[#'$get(counter)']'$loopend()

$puts(REM,'if composer is empty or eql -podcast- or -itunesu- fill it with the albumtags default value')

Thanks for helping me work my way through this.  
K

---

<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: [June 21, 2016, 2:26pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/8 "2016-06-21T14:26:22Z")

</div>

> [@rko31415](#):
>
> Sometimes just writing about an issue helps. I have solved the problem. ...

Well, I have to say, I do not understand why and what you are doing there, ...  
but it is somewhat remarkable, please explain, why do you do this?  
Why don't you walk the direct way and apply all the rules within one standard action group?

Does this help to understand how to remove an apostrophe character?  
From: COMPOSER \<== UCL - London's Global University

Action Format value  
Field: COMPOSER  
Formatstring: $replace(%COMPOSER%,$char(39),$char(0))

To: COMPOSER ==\> UCL - Londons Global University

DD.20160621.1826.CEST

> [@](#):
>
> Verbal explanation: for each album, if the composer exists and it's not 'podcast' or 'itunes u' then keep it, otherwise replace it with the album-level default composer

Try this ...

**Action: Format value Field: COMPOSER Formatstring: $iflonger($replace(%COMPOSER%,'podcast',,'iTunes U',),0,%COMPOSER%,%ALBUM\_DEFAULT\_COMPOSER%)**

... or ...

**Action: Format value Field: COMPOSER Formatstring: $iflonger($replace($lower(%COMPOSER%),'podcast',,'itunes u',),0,%COMPOSER%,%ALBUM\_DEFAULT\_COMPOSER%)**

DD.20160621.1916.CEST, DD.20160704.0921.CEST

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [June 27, 2016, 8:49pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/9 "2016-06-27T20:49:06Z")

</div>

Thanks for responding.

Each podcast has unique formatting, based on the author of the podcast. In order to listen to my podcasts in an orderly fashion I must harmonize them all, at least somewhat. Once I got above a few hundred podcasts the task became overwhelming.

I hit on the idea of maintaining the unique editing rules for each podcast in tiny (empty) mp3's, one for each album.

So I have a folder of tiny mp3's 1-to-1 with each podcast download folder. And each month I 'build' the Action Groups by parsing through this folder. Hence the Export Config solution.

Mostly these 'rules' embodied in the tiny mp3's don't change, but each month there are a half dozen or so that do. So I can't just have a standardize edit.

The Composer issue was just one of many (Title, Artist, Genre, PodcastURL, Comment, etc.).

Again thanks for helping me work my way through this (longstanding) issue.

K

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [July 3, 2016, 9:01pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/10 "2016-07-03T21:01:13Z")

</div>

My earlier solution was wrong. Some of the composers have commas in their names, so the output needs to be literalized (surrounded in single quotes). So how to literalize a blank composer?

The only solution I could come up with is to count the length of the composer and to manually fill in composers shorter than three (3) with an un-literalized blank.

REM Export Config to generate an Action Group  
REM Purpose is to replace blank composers with a default album-level composer  
$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U)),%composer%,  
$if($grtr($len('''$replace(%composer%,'','''''''')'''),2),'''$replace(%composer%,'','''''''')''',))

Examples of Generated Action Groups  
REM Composer with a comma  
$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U)),%composer%,  
$if($grtr($len('Composer w, a comma'),2),'Composer w, a comma',))

REM Composer with single apostrophe  
$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U)),%composer%,  
$if($grtr($len('example with '''' single apostrophe'),2),'example with '''' single apostrophe',))

REM Blank Composer  
$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U)),%composer%,$if($grtr($len(''),2),'',))

I noticed it doesn't work when there's a single apostrophe at the end of a composer, but I don't yet have that case.

So I still think there's a need for a way to literalize a blank output ... hence this should still be considered a 'bug' (or at least a needed enhancement).

K

---

<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: [July 4, 2016, 5:24am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/11 "2016-07-04T05:24:41Z")

</div>

> [@rko31415](#):
>
> My earlier solution was wrong. Some of the composers have commas in their names, so the output needs to be literalized (surrounded in single quotes). So how to literalize a blank composer? ...

See above post #3, a "string of nothing" can be created by **$char(0)**.

DD.20160704.0924.CEST

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [July 4, 2016, 10:57am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/12 "2016-07-04T10:57:07Z")

</div>

thanks. I tried all the above recommendations and none of them seemed to help.  
if you literalize $char(0) it doesn't execute to a blank

---

<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: [July 4, 2016, 3:49pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/13 "2016-07-04T15:49:57Z")

</div>

> [@rko31415](#):
>
> ... if you literalize $char(0) it doesn't execute to a blank

Apply it as it is: it is a function call.  
Note: $char(0) delivers nothing, which means, it is not a "blank".

DD.20160704.1949.CEST

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [July 4, 2016, 8:09pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/14 "2016-07-04T20:09:39Z")

</div>

I guess I'm not understanding. I meant empty, not blank.

I need one Export Config that can output an Action Group for three different cases

1. a composer containing a comma
2. 
3. a composer containing a single apostrophe

so the album-level composer can be of three flavors

1. master composer, the real master
2. 
3. master's composer

#'s 1 and 3 must be literalized, and #3 requires MANY single apostrophe's to achieve its goal. So how to use $char(0) for #2 if literalization must be used?

Can I impose on you to take a look at the example Export config I supplied and show me how I might use your $char(0) suggestion?

---

<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: [July 5, 2016, 5:17am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/15 "2016-07-05T05:17:53Z")

</div>

> [@rko31415](#):
>
> ... show me how I might use your $char(0) suggestion?

Maybe it can help at first to create the wanted actionsgroup in the normal way from within Mp3tag.  
Then open the actionsgroup's related mta script file with a text editor.  
Then copy the text and insert the apostrophes where it should be needed in order to create a proper mte export text file.  
Maybe, leave out function calls from 'literalization'?

DD.20160705.0917.CEST

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [July 5, 2016, 11:30am UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/16 "2016-07-05T11:30:52Z")

</div>

Then you agree it's a bug.

Each Action Group is ~1700 lines long (yes, that many albums). Hence the approach I took.

There are 12 of these massive action groups (title, album, genre, podcasturl, etc.).

My work-around functions fine for me now and doesn't require the manual steps you propose.

K

---

<div class="post-metadata">

### Author: ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)
#### Post date: [July 5, 2016, 12:07pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/17 "2016-07-05T12:07:11Z")

</div>

> [@rko31415](#):
>
> .....I need one Export Config that can output an Action Group for three different cases
> 
> 1. a composer containing a comma
> 2. 
> 3. a composer containing a single apostrophe
> 
> so the album-level composer can be of three flavors
> 
> 1. master composer, the real master
> 2. 
> 3. master's composer......

Hi rko31415.  
Using the Export function to write an MTA file: what a great idea!  
Maybe it's been done before, but this is the first time I've paid attention.  
I'll keep it in mind.

Try this Export script. It seems to work for the 3 specified cases.

```
$filename(C:\Documents and Settings\IDES\Application Data\Mp3tag\data\actions\Composer Fill.mta,UTF-8)'[#0]'$loop(%album%,1)

'T=5'
'F=COMPOSER'
'1=$if($eql(%album%,'$replace(%album%,'','''',',',''',''','[','''[''',']',''']''','%','''%''')'),$if($and(%composer%,$neql(%composer%,podcast),$neql(%composer%,iTunes U)),%composer%,'$replace(%composer%,'','''',',',''',''','[','''[''',']',''']''','%','''%''')'),%composer%)'$puts(counter,$add(1,$get(counter)))

'[#'$get(counter)']'$loopend()

$puts(REM,'if composer is empty or eql -podcast- or -itunesu- fill it with the albumtags default value')

```

It's always a challenge to parse somebody's code, especially when it is as "low-level" as Mp3tag scripts.  
It seems as if you are using the $regexp function to ensure that the album-level tags are applied to only the files of the corresponding album.  
However, my tests show that an apostrophe in the album-level ALBUM field will cause a syntax error.

Instead, I've used the $if($eql(w,x),y,z) structure.  
Here's the template:  
$if($eql(%album%, ALBUM\_LEVEL\_ALBUM), make changes (if appropriate) to %composer%, %composer%)

When writing the MTA file, various special characters must be escaped when writing ALBUM\_LEVEL\_ALBUM:  
$replace(%album%,',',''',''') to replace comma with escaped comma  
$replace(%album%,'[','''[''') to replace [ with escaped [  
$replace(%album%,']',''']''') to replace ] with escaped ]  
$replace(%album%,'%','''%''') to replace % with escaped %  
$replace(%album%,'','''') to replace apostrophe with escaped apostrophe  
(My tests showed that $ did not have to be escaped, which seems to be at odds with with the documentation.)

These can be combined into this single function:  
$replace(%album%,'','''',',',''',''','[','''[''',']',''']''','%','''%''')

And the same replace function is used when writing the album-level composer.

BTW, I changed $loop(%album%) to $loop(%album%,1).

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [July 5, 2016, 7:55pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/18 "2016-07-05T19:55:50Z")

</div>

ryerman,

Confirmed your export config works great. Even better than my work-around.

And the single function: $replace(%album%,'','''',',',''',''','[','''[''',']',''']''','%','''%''') is incredibly clever. I learn something new every day with this package.

K

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [July 6, 2016, 5:22pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/19 "2016-07-06T17:22:33Z")

</div>

just a quick addendum to the fabulous replace statement:

$replace(%album%,'','''',',',''',''','[','''[''',']',''']''','%','''%''',=,''\u003d'')

For podcasturl you'll need to escape the = sign, as I've included.

---

<div class="post-metadata">

### Author: ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)
#### Post date: [July 6, 2016, 11:00pm UTC](https://community.mp3tag.de/t/apostrophes-in-action-items/18049/20 "2016-07-06T23:00:05Z")

</div>

That's good. Thanks for posting that information.

This also works:  
$replace(%album%,'','''',',',''',''','[','''[''',']',''']''','%','''%''',=,\u003d)  
The equal sign does not need single quotes in the MTA file.

I guess there is some reason, but I can't readily understand or explain.

I won't be surprised if there are other characters that need to be escaped but haven't been needed yet.

[Next page](https://community.mp3tag.de/t/apostrophes-in-action-items/18049.md?page=2)
