# Remove characters based on (First N, Last N) from field.

**URL:** https://community.mp3tag.de/t/remove-characters-based-on-first-n-last-n-from-field/15935
**Category:** General Discussion
**Created:** [July 23, 2014, 1:49pm UTC](https://community.mp3tag.de/t/remove-characters-based-on-first-n-last-n-from-field/15935 "2014-07-23T13:49:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fohrums](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/8c91f0/32.png) [@fohrums](https://community.mp3tag.de/u/fohrums)
#### Post date: [July 23, 2014, 1:49pm UTC](https://community.mp3tag.de/t/remove-characters-based-on-first-n-last-n-from-field/15935/1 "2014-07-23T13:49:06Z")

</div>

My Genre field is set like so:

%genre%: Hip-Hop; East Coast Hip-Hop  
%genre%: Electronic; Drum & Bass

this was because I wanted to use MusicBee's auto-EQ feature which was based off 'grouping' tags (Electronic, Hip-Hop, Rock, etc). Now that i'm going back to Foobar2000 I didn't like how it's displayed and I made up my mind to revert back to good ole' (1) genre label like so:

%genre%: East Coast Hip-Hop  
%genre%: Drum & Bass

=============================

Now there are (2) ways to delete them:

#1. [First N, Last N] from which the number 'N' removed the relative amount of characters.  
I got this method from the utility 'Bulk Renamer'

#2 [Character Specific] delete the respective characters (most likely grouped) within %genre% including separators & spaces.

--info--  
nice read for music library organization for genre  
[http://www.blisshq.com/music-library-manag...sic-genre-list/](http://www.blisshq.com/music-library-management-blog/2011/01/25/fundamental-music-genre-list/)

---

<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 23, 2014, 3:30pm UTC](https://community.mp3tag.de/t/remove-characters-based-on-first-n-last-n-from-field/15935/2 "2014-07-23T15:30:12Z")

</div>

> [@fohrums](#):
>
> My Genre field is set like so:  
> %genre%: Hip-Hop; East Coast Hip-Hop ... and I made up my mind to revert ... genre label like so: %genre%: East Coast Hip-Hop ...

Make sure to see only those files which you want to manipulate ...  
Set Filter: GENRE MATCHES "^.+?;.+?$"  
... or ...  
Set Filter: GENRE HAS "; "

Begin Action Group **Test2014#20140723.SetGenreFromItem2** 

Action #1  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **GENRE**  
_Formatstring:_ **$replace(%GENRE%,'; ','\\')**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **GENRE**  
_Formatstring:_ **$meta(GENRE,1)**

 

End Action Group **Test2014#20140723.SetGenreFromItem2** (2 Actions)

 From: GENRE = Hip-Hop; East Coast Hip-Hop 

To: GENRE = East Coast Hip-Hop

 

... or ...

 

Action "Format value"  
Field: GENRE  
Formatstring: **$cutLeft(%GENRE%,$add($strstr(%GENRE%,'; '),1))**  
... or ...  
Formatstring: **$ifgreater($strstr(%GENRE%,'; '),0,$cutLeft(%GENRE%,$add($strstr(%GENRE%,'; '),1)),%GENRE%)**

 

DD.20140723.1935.CEST, DD.20140724.1329.CEST

---

<div class="post-metadata">

### Author: ![fohrums](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/8c91f0/32.png) [@fohrums](https://community.mp3tag.de/u/fohrums)
#### Post date: [July 24, 2014, 7:54am UTC](https://community.mp3tag.de/t/remove-characters-based-on-first-n-last-n-from-field/15935/3 "2014-07-24T07:54:37Z")

</div>

> [@DetlevD](#):
>
> Begin Action Group **Test2014#20140723.SetGenreFromItem2** 
> 
> ... or ...
> 
>  
> 
> Action "Format value"  
> Field: GENRE  
> Formatstring: [size=1][font="Courier New"]**$cutLeft(%GENRE%,$add($strstr(%GENRE%,'; '),1))**
> 
>  
> 
> DD.20140723.1935.CEST

I prefer this one as it's simply a shorter method. BUT, is there a way to notify the genre tag if it doesn't have anything before "'; " (yes, including that space) then don't apply this command. Otherwise it removes one character from beginning N like so:

East Coast Hip-Hop \> ast Coast Hip-Hop  
Drum & Bass \> rum & Bass

![:huh:](https://community.mp3tag.de/uploads/default/original/1X/f15ee73c0fd9ec3b0db7481f0558638f8ee224ce.gif ":huh:")

---

<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: [July 24, 2014, 8:00am UTC](https://community.mp3tag.de/t/remove-characters-based-on-first-n-last-n-from-field/15935/4 "2014-07-24T08:00:26Z")

</div>

> [@fohrums](#):
>
> I prefer this one as it's simply a shorter method. BUT, is there a way to notify the genre tag if it doesn't have anything before "'; " (yes, including that space) then don't apply this command. Otherwise it removes one character from beginning N like so:
> 
> East Coast Hip-Hop \> ast Coast Hip-Hop  
> Drum & Bass \> rum & Bass
> 
> ![:huh:](https://community.mp3tag.de/uploads/default/original/1X/f15ee73c0fd9ec3b0db7481f0558638f8ee224ce.gif ":huh:")

What about an action of the type "Replace with regular expression" for GENRE  
Search string: .\*;  
(with a blank at the end)  
Replace String:  
(leave that empty).  
This should delete that part of a string that is in front of a "; ".
