# Regex first character Alphabet only

**URL:** https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502
**Category:** Support
**Created:** [February 28, 2013, 4:34pm UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502 "2013-02-28T16:34:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![PerfectVirus](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/b5a626/32.png) [@PerfectVirus](https://community.mp3tag.de/u/PerfectVirus)
#### Post date: [February 28, 2013, 4:34pm UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/1 "2013-02-28T16:34:12Z")

</div>

If have used Regex before but I am stumbling over trying to determine %artist% that begin with alphabet character. I am trying to batch convert tag to filename.

I have several artists that begin with numeric or non-alphabet characters:

.38 Special  
+44  
3 Doors Down  
(Crosses)

I would like these to to move to a folder named 0-9 and those starting with alphabet character to move to A...Z fodlers based on their first letter.

Here is what I came up with but everything moves to 0-9

```
$if((((NOT %artist% MATCHES ^\w) OR (%artist% MATCHES ^\d))),0-9\\%artist%,$left(%artistsort%,1)\\%artist%))

```

I have also trie the following:

```
$if(($or(($not(%artist% MATCHES ^[a-zA-Z])),(%artist% MATCHES ^\d))),"0-9\"%artist%,$left(%artistsort%,1)\\%artist%))

$if((%artist% MATCHES ^\W),0-9,$left(%artistsort%,1)))

```

Any suggestions?

---

<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: [February 28, 2013, 6:06pm UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/2 "2013-02-28T18:06:00Z")

</div>

Please don't forget:  
Where do you want to move special characters like Д or Э or Ø or 菅?  
Should they go to 0-9 too?

And there some more like  
!distain  
[product]  
.hiDDen tiMe  
!!!

There are even some characters who seems to be between A-Z (example: ВЕЧЕ or РАРОГЪ), but the B and P are not the usual one...

Sorry, not really helpful. Just my 2 cents.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [February 28, 2013, 6:16pm UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/3 "2013-02-28T18:16:04Z")

</div>

You mixed Filter syntax with script functions, that's not supported.

Try this:  
$iflonger($regexp($left(%artist%,1),'^[.+(\d]',0-9),2,0-9,$left(%artistsort%,1))

---

<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: [September 9, 2014, 10:40am UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/4 "2014-09-09T10:40:35Z")

</div>

> [@PerfectVirus](#):
>
> ... I have several artists that begin with numeric or non-alphabet characters:  
> .38 Special  
> +44  
> 3 Doors Down  
> (Crosses)  
> I would like these to to move to a folder named 0-9 and those starting with alphabet character to move to A...Z fodlers based on their first letter. ... Any suggestions?

**$ifgreater($len(%ARTIST%),$len($regexp(%ARTIST%,'^[^[:alpha:]]',)),'0-9',$upper($left(%ARTIST%,1)))**

... or ...

**$iflonger(%ARTIST%,$len($regexp(%ARTIST%,'^[^[:alpha:]]',)),'0-9',$upper($left(%ARTIST%,1)))**

DD.20140910.0900.CEST

---

<div class="post-metadata">

### Author: ![triks\_melb](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/3be4f8/32.png) [@triks\_melb](https://community.mp3tag.de/u/triks_melb)
#### Post date: [June 23, 2023, 5:35am UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/5 "2023-06-23T05:35:31Z")

</div>

sorry if this is posted somewhere else but I wasn't able to find anywhere. If I could ask for Step by step instructions for newbies on how to; move artist folders into alphabetical folders - have tried this command but I don't know how to run it in mp3tag

```auto
$iflonger(%ARTIST%,$len($regexp(%ARTIST%,'^[^[:alpha:]]',)),'0-9',$upper($left(%ARTIST%,1)))

```

Current folder/file structure:  
`%artists% \ %album% (%year%)\%artist% - %title%.ext`

I would like mp3tag to create a folder from first letter of %artist% then move all artists matching the same first letter to the new folder (keeping the subfolder structures).

New folder structure:  
1 \ %artists% \ %album% (%year%) \ %artist% - %title%.ext  
2 \ %artists% \ %album% (%year%) \ %artist% - %title%.ext  
a \ %artists% \ %album% (%year%) \ %artist% - %title%.ext  
b \ %artists% \ %album% (%year%) \ %artist% - %title%.ext

thank you in advance

---

<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 23, 2023, 5:54am UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/6 "2023-06-23T05:54:43Z")

</div>

In general: if you want to rename a folder, then use an action of the type "Format value" for \_DIRECTORY.  
BUT: as you do not want to rename just the current folder but also the parent folder, you will be left with empty folders after the process.  
Only the current folder level can be renamed.  
Also, I would apply a full path like  
`d:\music\1\ %artists% \ %album% (%year%) \ %artist% - %title%.ext`  
in order to get the same starting point.  
(instead of the "1" insert the regular expression)  
And finally, the field ARTISTS is no standard field - there are ARTIST and ALBUMARTIST. Are you sure that you have that field filled in in every track if you reference that in your string?

See also here:

> [@Script for first letter groups for folder names](https://community.mp3tag.de/t/script-for-first-letter-groups-for-folder-names/60390):
>
> There have been a couple of posts on this topic, e.g. [here](https://community.mp3tag.de/t/renaming-create-grouping-directories-of-3-letters/16986), but I thought I'd share my solution to creating a folder grouping of a certain number of letters, using the first letter of a sort field (falling back to main field if empty). This is useful for players that struggle with long lists, like in a car. The formula produces the letter group folder name that you can include in your complete file path when doing a tag - filename action, e.g. "E:\Music\Classical\A-D\Bach, Johann Sebastian..." …

---

<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: [July 23, 2023, 5:55am UTC](https://community.mp3tag.de/t/regex-first-character-alphabet-only/14502/7 "2023-07-23T05:55:38Z")

</div>

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