# Replacing genre in embedded CUESHEET

**URL:** <https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550>\
**Category:** Support\
**Created:** [January 14, 2016, 6:36pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550 "2016-01-14T18:36:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsa999](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@gsa999](https://community.mp3tag.de/u/gsa999)\
**Post date:** [January 14, 2016, 6:36pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/1 "2016-01-14T18:36:50Z")

</div>

Using a Format Value Action I am trying to replace the genre in the embedded cuesheet with the actual genre (which has changed since first rip)

Trying this, but its not working

$regexp(%cuesheet%,’^(.\*?REM GENRE )(.+?)$’,‘$1”%GENRE%”’)

The double quotes round %genre% are to handle genres with a space in them

Any ideas what I am doing wrong.

Thanks  
G

---

<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:** [January 14, 2016, 8:14pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/2 "2016-01-14T20:14:10Z")

</div>

> [@gsa999](#):
>
> Any ideas what I am doing wrong.  
> G

Double quotes: use " not ”  
Single quotes: use ' not ’

---

<div class="post-metadata">

**Author:** ![gsa999](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@gsa999](https://community.mp3tag.de/u/gsa999)\
**Post date:** [January 15, 2016, 5:54am UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/3 "2016-01-15T05:54:06Z")

</div>

> [@ryerman](#):
>
> Double quotes: use " not ”  
> Single quotes: use ' not ’

Thanks. That is a lot better now but it is not picking up the genre correctly instead its replacing the old genre with the text %GENRE%.

G

---

<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 15, 2016, 6:00am UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/4 "2016-01-15T06:00:14Z")

</div>

> [@gsa999](#):
>
> Thanks. That is a lot better now but it is not picking up the genre correctly instead its replacing the old genre with the text %GENRE%.
> 
> G

I would say that the last part should be  
,$1%GENRE%)  
without any quotes

---

<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:** [January 15, 2016, 9:30am UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/5 "2016-01-15T09:30:44Z")

</div>

> [@gsa999](#):
>
> Using a Format Value Action I am trying to replace the genre in the embedded cuesheet with the actual genre (which has changed since first rip) ...

**CUESHEET \<== $regexp(%cuesheet%,'^(.\*REM GENRE )(.+?)([\r\n]+.\*)$','$1'%GENRE%'$3') ... or ... CUESHEET \<== $regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1'%GENRE%'$2')**

DD.20160115.1215.CET

---

<div class="post-metadata">

**Author:** ![gsa999](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@gsa999](https://community.mp3tag.de/u/gsa999)\
**Post date:** [January 15, 2016, 11:19am UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/6 "2016-01-15T11:19:25Z")

</div>

> [@DetlevD](#):
>
> **CUESHEET \<== $regexp(%cuesheet%,'^(.\*REM GENRE )(.+?)([\r\n]+.\*)$','$1'%GENRE%'$3') ... or ... CUESHEET \<== $regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1'%GENRE%'$2')**
> 
> DD.20160115.1215.CET

Excellent, thanks this works (I used the second shorter version) perfectly.  
I now want to add an If condition to check whether the GENRE has a space in it or not. If it does it needs to be inserted in quotes in the cuesheet; if no space it does not need quotes. I tried this but it just shows the code in the cuesheet

```
$regexp(%cuesheet%,'(.*REM GENRE ).+?($.*)','$1($if($eql($strstr(%GENRE%,\s)),0,'%GENRE%',"'%GENRE%'"))$2')

```

---

<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:** [January 15, 2016, 12:50pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/7 "2016-01-15T12:50:46Z")

</div>

> [@gsa999](#):
>
> ... I now want to add an If condition to check whether the GENRE has a space in it or not. If it does it needs to be inserted in quotes in the cuesheet; if no space it does not need quotes. ...

I have tested my regexp proposal with a tagfield set to GENRE \<== 'Pop Rock' ...  
that means within the tagfield GENRE there are no quote characters, ...  
and the regexp works.

But within the cuesheet itself ...  
[https://de.wikipedia.org/wiki/Cuesheet](https://de.wikipedia.org/wiki/Cuesheet)  
[https://en.wikipedia.org/wiki/Cue\_sheet\_(computing)](https://en.wikipedia.org/wiki/Cue_sheet_(computing))  
... there are double quotes used in the REM lines, ...  
when there is ... t e x t ... which contains space characters ... or not.

Therefore, for sure, write always double quotes around the text.

**CUESHEET \<== $regexp(%cuesheet%,'^(.\*REM GENRE )(.+?)([\r\n]+.\*)$','$1"'%GENRE%'"$3') ... or ... CUESHEET \<== $regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1"'%GENRE%'"$2')**

Maybe you have to repair doubled double-quotes ...

**CUESHEET \<== $replace(%cuesheet%,'""','"')**

DD.20160115.1500.CET

---

<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:** [January 15, 2016, 4:03pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/8 "2016-01-15T16:03:53Z")

</div>

> [@gsa999](#):
>
> ... $regexp(%cuesheet%,'(._REM GENRE ).+?($._)','$1($if($eql($strstr(%GENRE%,\s)),0,'%GENRE%',"'%GENRE%'"))$2')

The quoted formatstring has no correct syntax.

It should be written as ...

**$regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1'$ifgreater($strstr(%GENRE%,' '),0,'"'%GENRE%'"',%GENRE%)'$2') ... or ... $regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1'$ifgreater($strchr(%GENRE%,' '),0,'"'%GENRE%'"',%GENRE%)'$2')**

DD.20160115.1803.CET

---

<div class="post-metadata">

**Author:** ![gsa999](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@gsa999](https://community.mp3tag.de/u/gsa999)\
**Post date:** [January 16, 2016, 7:12pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/9 "2016-01-16T19:12:41Z")

</div>

> [@DetlevD](#):
>
> The quoted formatstring has no correct syntax.
> 
> It should be written as ...
> 
> **$regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1'$ifgreater($strstr(%GENRE%,' '),0,'"'%GENRE%'"',%GENRE%)'$2') ... or ... $regexp(%cuesheet%,'(.\*REM GENRE ).+?($.\*)','$1'$ifgreater($strchr(%GENRE%,' '),0,'"'%GENRE%'"',%GENRE%)'$2')**
> 
> DD.20160115.1803.CET

Thanks so much, I messed around for ages trying to get the $if statement to work. This works perfectly. I used the second version.

Thanks

G

---

<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 9, 2026, 12:26pm UTC](https://community.mp3tag.de/t/replacing-genre-in-embedded-cuesheet/17550/10 "2026-02-09T12:26:03Z")

</div>

Closed on February 9, 2026, 12:26pm UTC


