# Genre From Filename?

**URL:** https://community.mp3tag.de/t/genre-from-filename/10605
**Category:** Support
**Created:** [July 1, 2010, 4:06pm UTC](https://community.mp3tag.de/t/genre-from-filename/10605 "2010-07-01T16:06:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![l0kl1n](https://community.mp3tag.de/user_avatar/community.mp3tag.de/l0kl1n/32/326_2.png) [@l0kl1n](https://community.mp3tag.de/u/l0kl1n)
#### Post date: [July 1, 2010, 4:06pm UTC](https://community.mp3tag.de/t/genre-from-filename/10605/1 "2010-07-01T16:06:09Z")

</div>

Hello All,

I was wondering if anyone can maybe point me in the right direction here.

Is it possible to create an action that will update the genre for an album from the title of a text file?

For example, say I have an album in a directory and I have one text file called:  
00 ~ Genre ~ Electronic - Minimal-Tech House.txt

Would it be possible to update genre to "Electronic - Minimal-Tech House". I can't think of a way to do it.

Again, any pointers would be much appreciated.

---

<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 2, 2010, 3:22am UTC](https://community.mp3tag.de/t/genre-from-filename/10605/2 "2010-07-02T03:22:59Z")

</div>

> [@l0kl1n](#):
>
> For example, say I have an album in a directory and I have one text file called:  
> 00 ~ Genre ~ Electronic - Minimal-Tech House.txt
> 
> Would it be possible to update genre to "Electronic - Minimal-Tech House". I can't think of a way to do it.
> 
> Again, any pointers would be much appreciated.

So, you have used a file name to store information that should appear inside a file?  
MP3tag has some functions that consider the filename (of mp3 files) and/or the directory name.  
As -so I take it - the genre is something to be valid for all the files in a directory, I suggest that you use the means of the filesystem to transfer the information.  
So write yourself a batch job that  
a) finds all the 00-Files and writes them to a file  
(open a cmd window, execute  
dir /s 00\*.txt \> genrefiles.txt  
then edit the file genrefiles.txt so that you append the directory names by the filename, e.g.  
Beatles - Revolver  
becomes  
Beatles - Revolver \_ 00 - Genre - Beat Music  
use the dos-commands  
cd  
ren  
to rename the directories.  
THen open MP3tag and use the function "Filename - Tag" with a mask like  
%dummy% - %dummy% \_ 00 - Genre - %genre%

So: To my opinion this will take an awful lot of time and I think you are much better off to scan through the directories manually and enter the genre manually also.

---

<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 2, 2010, 12:22pm UTC](https://community.mp3tag.de/t/genre-from-filename/10605/3 "2010-07-02T12:22:20Z")

</div>

> [@ohrenkino](#):
>
> ... I suggest that you use the means of the filesystem to transfer the information.  
> So write yourself a batch job that  
> a) finds all the 00-Files and writes them to a file  
> (open a cmd window, execute  
> dir /s 00\*.txt \> genrefiles.txt  
> then edit the file genrefiles.txt so that you append the directory names by the filename, e.g.  
> Beatles - Revolver  
> becomes  
> Beatles - Revolver \_ 00 - Genre - Beat Music  
> use the dos-commands  
> cd  
> ren  
> to rename the directories.  
> THen open MP3tag and use the function "Filename - Tag" with a mask like  
> %dummy% - %dummy% \_ 00 - Genre - %genre% ...

Interesting proposal by ohrenkino!  
This folder renaming trick sounds to be feasable.

But the cmd.exe command line needs some refinement.  
Example:  
**cmd.exe /cdir /b/s/-p "O:\TEST\00 ~ Genre ~\*.txt" \>\>O:\TEST\ListOfGenreFiles.txt**

This will create a text file, which contains a list of filepathes.  
Example:  
O:\TEST\T1\Divers\00 ~ Genre ~ Electronic - Minimal-Tech House.txt  
O:\TEST\T1\Rock\00 ~ Genre ~ Rock - Alternative.txt

Then you can use this list as input for another batch command file, which does the job of renaming the folder:  
Read each line.  
Get old folderpath.  
Replace "\00" with " ~ 00".  
Replace ".txt" with "" (... or suppress file extension).  
Create new folderpath.  
Do the folder renaming from old folderpath to new folderpath.

Example:  
Rename  
O:\TEST\T1\Divers  
to  
O:\TEST\T1\Divers ~ 00 ~ Genre ~ Electronic - Minimal-Tech House

Rename  
O:\TEST\T1\Rock  
to  
O:\TEST\T1\Rock ~ 00 ~ Genre ~ Rock - Alternative

Make sure, that you have a second batch command file, which is able to revert the folder renaming afterwards, after the GENRE tag fields have been set.

The GENRE tag field can be set from partly content of the pseudo tag field \_DIRECTORY.

Example using action "Format value" along with function regexp():  
Tag field: **GENRE**  
Format string: **$regexp(%\_DIRECTORY%,'^(.+?) ~ (.+?) ~ (.+?) ~ (.+?)$','$4')**  
will set the tag field GENRE to:  
**Electronic - Minimal-Tech House**

Example using action "Guess values":  
Source format: **%\_DIRECTORY%**  
Guessing pattern: **%DUMMY% ~ %DUMMY% ~ %DUMMY% ~ %GENRE%**  
will set the tag field GENRE to:  
**Electronic - Minimal-Tech House**

The last step is to rename the folders back to their original folder name.  
This can be done eiither from inside of Mp3tag by setting the pseudo tag field \_DIRECTORY to a value created from other tag fields, or from outside of Mp3tag by an external batch command file.

DD.20100702.1619.CEST

---

<div class="post-metadata">

### Author: ![l0kl1n](https://community.mp3tag.de/user_avatar/community.mp3tag.de/l0kl1n/32/326_2.png) [@l0kl1n](https://community.mp3tag.de/u/l0kl1n)
#### Post date: [July 3, 2010, 12:54am UTC](https://community.mp3tag.de/t/genre-from-filename/10605/4 "2010-07-03T00:54:06Z")

</div>

Awesome & thank you both very much for your time.

I successfully changed my directories to include the genre in the directory name and then re-tagged everything with a guess value that picked up the genre. Don't know why I didn't think of that - it is a much easier solution.

MP3Tag is sure a swell program -- I can't believe how much time I have spent manually tagging things before.

Again, thanks.

---

<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:22pm UTC](https://community.mp3tag.de/t/genre-from-filename/10605/5 "2026-02-09T12:22:28Z")

</div>


