# Automate Filename-Tag using Actions

**URL:** https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906
**Category:** Support
**Created:** [July 30, 2021, 12:18pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906 "2021-07-30T12:18:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![HellPhantom](https://community.mp3tag.de/user_avatar/community.mp3tag.de/hellphantom/32/9565_2.png) [@HellPhantom](https://community.mp3tag.de/u/HellPhantom)
#### Post date: [July 30, 2021, 12:18pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906/1 "2021-07-30T12:18:28Z")

</div>

Hi,  
I would like to import some folder names (2 levels to be exact) as multiple albums on movies

I just need a working Action example then I should be able to tinker with it myself from there.

Filename on Disk  
i:\Multimedia\Movies\Dracula\Bloodthirsty Trilogy\Evil of Dracula (1974)\Evil of Dracula (1974).[6.5★].[1080p.x264.Bluray.2.500Kbps.23.976Fps].[1.0.AAC].[jpn].{imdb-tt0071308}.mp4

1. Filename-Tag  
%album%%album%%dummy%%dummy%  
Gives this output in preview. album: Dracula Bloodthirsty Trilogy  
This is the output I would like. album: Dracula /Bloodthirsty Trilogy  
It represents 2 albums or collections and must be separated by "/", I don't know how to add the "/".

It does not appear that I can format the output with Filename-Tag and needs to do this with Actions.

I have tried to create an Action to automate this but I really just don't know how.  
I created a new Action of type Format value and I can bring the %\_PATH% into the album field but I don't know how to extract the values from the path. Maybe there is a simpler way.

Field: ALBUM  
Format String: %\_PATH%

I'd appreciate some help.  
Thanks,

---

<div class="post-metadata">

### Author: ![HellPhantom](https://community.mp3tag.de/user_avatar/community.mp3tag.de/hellphantom/32/9565_2.png) [@HellPhantom](https://community.mp3tag.de/u/HellPhantom)
#### Post date: [July 30, 2021, 1:42pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906/2 "2021-07-30T13:42:00Z")

</div>

I played with this statement.  
Nr 1. It is close and Nr 2. Is what i want but I dont like the hardcoding of the drive, i have many drives and the "Multimedia" and the Movies bit. I would prefer something more dynamic where I could rather extract different parent folder levels. Like when you specify ./ or ../ in Filebot. Then it is easy to extract 1, 2 or 3 levels. not having to exclude but rather extract what I need. It still seems the Action is more flexible and manageable and I can create variants for different levels.

1. Convert "Tag-Tag"  
Field: ALBUM  
Formatstring: $replace('^'%\_folderpath%,'^I:',,%\_directory%,,'',' /')  
Multimedia /Movies /Dracula /Bloodthirsty Trilogy

2. Convert "Tag-Tag"  
Field: ALBUM  
Formatstring: $replace('^'%\_folderpath%,'^I:',,%\_directory%,,'Multimedia',,'Movies',,'',' /')  
Dracula /Bloodthirsty Trilogy

---

<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: [July 30, 2021, 1:49pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906/3 "2021-07-30T13:49:39Z")

</div>

Maybe you can reach your goal with some of this variables:

> **[Converters – Mp3tag Documentation](https://docs.mp3tag.de/converters/)**
>
> Converters. Mp3tag is the universal Tag Editor.

especially:  
`%_directory%` ---\> Name of the parent directory  
`%_parent_directory%` ---\> Name of the grandparent folder

And maybe this approach can help too:

> [@Easy way to get directory names above Parent?](https://community.mp3tag.de/t/easy-way-to-get-directory-names-above-parent/9324/6):
>
> Following example of an Action Group "SplitFolderpath" demonstrates how to split the content of the Mp3tag system variable \_FOLDERPATH into it's folder components and make the folder names available for scripting by owner defined tag fields. MY\_FOLDER\_0 is the parent folder of the related file. MY\_FOLDER\_1 is the next folder up. MY\_FOLDER\_2 is the folder two steps up. ... and so on. Begin Action Group SplitFolderpath Action #1 Actiontype 5: Format tag field Field: MY\_FOLDERPATH Formatst…

---

<div class="post-metadata">

### Author: ![HellPhantom](https://community.mp3tag.de/user_avatar/community.mp3tag.de/hellphantom/32/9565_2.png) [@HellPhantom](https://community.mp3tag.de/u/HellPhantom)
#### Post date: [July 30, 2021, 1:55pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906/4 "2021-07-30T13:55:25Z")

</div>

> [@Easy way to get directory names above Parent?](https://community.mp3tag.de/t/easy-way-to-get-directory-names-above-parent/9324/6):
>
> MY\_FOLDER\_0 i

This example sounds promising and more what I would like. I will have to see if i can get it to work.

I also have this one now which at least does not hardcode the Drive.

$replace(%\_folderpath%,$left(%\_folderpath%,3),,%\_directory%,,'Multimedia\Movies',,'',' /')

---

<div class="post-metadata">

### Author: ![HellPhantom](https://community.mp3tag.de/user_avatar/community.mp3tag.de/hellphantom/32/9565_2.png) [@HellPhantom](https://community.mp3tag.de/u/HellPhantom)
#### Post date: [July 30, 2021, 2:37pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906/5 "2021-07-30T14:37:41Z")

</div>

Thanks for the Example just what I needed.  
I will post my Level 3 Action I created, I created 3 actions for now. A level 1, Level 2 and a Level 3.  
I can now easily use the Level I need.

Action #1  
\*Actiontype: **Format Value**  
\*Field: **MY\_FOLDERPATH**  
\*Formatstring: `%_FOLDERPATH%`

Action #2  
\*Actiontype: **Split fields by separator**  
\*Field: **MY\_FOLDERPATH**  
\*Separator: `\`

Action #3  
\*Actiontype: **Format Value**  
\*Field: **ALBUM**  
\*Formatstring: `$meta(MY_FOLDERPATH,$sub($folderdepth(%_FOLDERPATH%),1))`

Action #4  
\*Actiontype: **Format Value**  
\*Field: **ALBUM**  
\*Formatstring: `%album% /$meta(MY_FOLDERPATH,$sub($folderdepth(%_FOLDERPATH%),2))`

Action #5  
\*Actiontype: **Format Value**  
\*Field: **ALBUM**  
\*Formatstring: `%album% /$meta(MY_FOLDERPATH,$sub($folderdepth(%_FOLDERPATH%),3))`

Action #6  
\*Actiontype: **Remove Field**  
\*Field: **ALBUM**  
\*Fields to remove (semicolon separated): MY\_FOLDERPATH

Thanks again, hope I did not make any paste errors

---

<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: [August 29, 2021, 2:38pm UTC](https://community.mp3tag.de/t/automate-filename-tag-using-actions/53906/6 "2021-08-29T14:38:10Z")

</div>

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