# Automatically add Cover Art based on Directory/Folder name

**URL:** <https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033>\
**Category:** Support\
**Created:** [November 12, 2019, 5:00pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033 "2019-11-12T17:00:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpirosG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/spirosg/32/8589_2.png) [@SpirosG](https://community.mp3tag.de/u/SpirosG)\
**Post date:** [November 12, 2019, 5:00pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033/1 "2019-11-12T17:00:39Z")

</div>

HI, i would like to know if there is any way to create an action to automatically add cover arts in .mp3 files based on Directory/Folder name

For example i was thinking to create a folder with all the cover arts i want and name all the covers based on the music folders i want to add them to.

**E:\Covers and in there there is a jpg named MUSICCITY.jpg**

Now i want to automatically add that image to every file using mp3tag if the Directory contains MUSICCITY

**E:\New music\MUSICCITY (November 2019)**

So actualy something like

\ ***IF Path contains E:\New music\MUSICCITY Replace/Add all cover arts with MUSICCITY.jpg from _E:\Covers_**

Is there any way to do that?

---

<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:** [November 12, 2019, 5:33pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033/2 "2019-11-12T17:33:53Z")

</div>

From your example I do not see that the cover picutre files actually have the name of the folder of the music files.  
Cover:

> [@SpirosG](#):
>
> MUSICCITY.jpg

folder:

> [@SpirosG](#):
>
> MUSICCITY (November 2019)

There is something extra in the folder name which means that folder name and cover file name do not match.

Now you have to tell us which part of the folder name has to be left out or whether you want to rename the cover files so that folder and file names match.

The general background:  
There is an action [Import Cover from File – Mp3tag Documentation](https://docs.mp3tag.de/actions/import-cover)  
to import covers.  
So if the cover file name and the folder name would match 100% you could use for the cover file name the  
Format string: `e:\covers\%_directory%.jpg`  
It will become very tricky if you want MP3tag to guess which is the correct filename.

---

<div class="post-metadata">

**Author:** ![SpirosG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/spirosg/32/8589_2.png) [@SpirosG](https://community.mp3tag.de/u/SpirosG)\
**Post date:** [November 12, 2019, 5:44pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033/3 "2019-11-12T17:44:38Z")

</div>

Firstly thanks @ohrenkino for the fast reply.

This was just an example, usually my folders have the structure below

MUSICCITY 0511  
MUSICCITY 0611  
Or  
Crate Diggerz 0511  
Crate Diggerz 0611

Actualy the numbers represent the date, 5th of November for example, so can they be left out of the String?

So Actually

**IF Path contains E:\New music\MUSICCITY Replace/Add MUSICCITY.jpg from E:\Covers**  
**IF Path contains E:\New music\Crate Diggerz Replace/Add Crate Diggerz.jpg from E:\Covers**

---

<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:** [November 12, 2019, 6:12pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033/4 "2019-11-12T18:12:54Z")

</div>

You could try the following  
Format string: `e:\covers\$regexp(%_directory%,'(.*?) \d+$',$1).jpg`

---

<div class="post-metadata">

**Author:** ![SpirosG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/spirosg/32/8589_2.png) [@SpirosG](https://community.mp3tag.de/u/SpirosG)\
**Post date:** [November 12, 2019, 6:21pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033/5 "2019-11-12T18:21:25Z")

</div>

> [@ohrenkino](#):
>
> You could try the following  
> Format string: `e:\covers\$regexp(%_directory%,'(.*?) \d+`,$1).jpg`

Once again you did the trick, i've done some tests and it seems to be working correctly. 👍:👏🙌

Thank you @ohrenkino

---

<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:** [December 12, 2019, 6:27pm UTC](https://community.mp3tag.de/t/automatically-add-cover-art-based-on-directory-folder-name/47033/6 "2019-12-12T18:27:47Z")

</div>

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