# Directory Structure Help

**URL:** https://community.mp3tag.de/t/directory-structure-help/63261
**Category:** Support
**Created:** [December 31, 2023, 3:28am UTC](https://community.mp3tag.de/t/directory-structure-help/63261 "2023-12-31T03:28:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jiggerpine](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@Jiggerpine](https://community.mp3tag.de/u/Jiggerpine)
#### Post date: [December 31, 2023, 3:28am UTC](https://community.mp3tag.de/t/directory-structure-help/63261/1 "2023-12-31T03:28:55Z")

</div>

I apologize if this has been asked before. I tried several types of searches but none related to my question. I tried to use an well known online AI but ever since the last update it has become totally useless.  
It suggested the following but it did not work:  
`$if($eql(%albumartist%,Various Artists),COMPILATION,$if($eql($regexp($left($if2(%albumartistsort%,#), 1), '^[A-Za-z]$'),1),$upper($left($if2(%albumartistsort%,#), 1)),#))`

Basically, I am trying to create a high level directory. If the %albumartist% is "Various Artists" then the directory should be "Compilation", otherwise if the first character of the %albumartistsort% field is a letter than use that letter in uppercase, otherwise, if not a letter, use "#" as the directory.

Where I am stuck is how to check whether the first character of %albumartistsort% is a letter or not. The online AI suggested using a regexp but it's not working.

TIA

---

<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: [December 31, 2023, 7:48am UTC](https://community.mp3tag.de/t/directory-structure-help/63261/2 "2023-12-31T07:48:55Z")

</div>

Before you start with a complicated expression - why not use a filter and then treat the cases individually?  
e.g.  
%albumartist% IS "Various Artists"  
should filter all the files that are part of a compilation.  
Then you see whether you have to rename the files or the folders to get your directory structure.

To filter for non-alphabet characters, try  
`NOT "$left(%artist%,1)" MATCHES "[A-Z]"`  
or the other way round: for alphabetic characters:  
`"$left(%artist%,1)" MATCHES "[A-Z]"`

I would assume that it happens once in a lifetime of a file that it gets moved to a new folder structure. So the interactive process should be much easier to handle.

To rename a folder/file, try:  
`$ifgreater($strstr(ABCDEFGHIJKLMNOPQRSTUVWXYZ,$left(%artist%,1)),0,$left(%artist%,1),#)`

---

<div class="post-metadata">

### Author: ![Jiggerpine](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@Jiggerpine](https://community.mp3tag.de/u/Jiggerpine)
#### Post date: [December 31, 2023, 5:56pm UTC](https://community.mp3tag.de/t/directory-structure-help/63261/3 "2023-12-31T17:56:24Z")

</div>

Upon further reflection and finally figuring out how the regex expression worked I managed to get it working. Here is the solution that worked for me.

`$if($eql(%albumartist%,Various Artists),Compilation,$if($eql($regexp($left(%albumartistsort%,1),'^[A-Za-z]$',YES,1),YES),$left(%albumartistsort%,1),#))`

---

<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: [January 30, 2024, 5:56pm UTC](https://community.mp3tag.de/t/directory-structure-help/63261/5 "2024-01-30T17:56:31Z")

</div>

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