# Challenge to import cover from file

**URL:** https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601
**Category:** Support
**Created:** [January 29, 2016, 11:47pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601 "2016-01-29T23:47:21Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![eblankers](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@eblankers](https://community.mp3tag.de/u/eblankers)
#### Post date: [January 29, 2016, 11:47pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/1 "2016-01-29T23:47:21Z")

</div>

Hi,

now that I have my Music Folder organized and all my audio files nicely renamed and tagged, it is time to finalize the job and add the album covers. Now this turns out to be quite a challenge and doing it manually album by album is just not an option.

So I looked into using the Action "Import cover from file" but I can only get it to work when my .jpg reside in the same folder (or subfolder there of) as the .mp3 file as in the first example for the files in folder "Eddi - 2015 - Play Yer Guitar (EP)" but not for "Eddi - 2016 - Challenge"

So basically the structure is always something like this

D:\MUSIC  
|  
|  
|  
---Eddi

```
+---Eddi - 2015 - Play Yer Guitar (EP)
| | 01 - Intro.mp3
| | 02 - Outro.mp3
| |   
| \---Scans
| NiceCover_1.jpg
| NiceCover_2.jpg
|           
\---Eddi - 2016 - Challenge
    +---CD1
    | 01 - Intro.mp3
    | 02 - Chorus.mp3
    |       
    +---CD2
    | 01 - Solo.mp3
    | 02 - Outro.mp3
    |       
    \---Scans
            NoCover_1.jpg
            NoCover_2.jpg

```

So as soon as the audio files are one level deeper than the album covers as in the folder "Eddi - 2016 - Challenge" the Action no longer works and I keep getting the error message saying "Import cover from file "Scans\*.jpg" (Front Cover): File D:\Music\Eddi\Eddi - 2016 - Challenge\CD1\Scans\*.jpg cannot be accessed.

I understand that the message is legitimate since there is no Scans folder in the CD1 (and CD2) subfolder. But what is the solution to this? I certainly do not want to restructure my MUSIC directory. Placing the .jpg files one level deeper to get it to work would also mean that I would need to put copy all imagr files into BOTH the CD1 and CD2 folder. I am convinced that there is some smarter way to do it, but I just do not see how.

The Help file states that this Action "Imports the cover art specified by the absolute or relative filename into the tag of the file" -- unfortunately it does not say absolute or relative path!

So instead of setting the Action's "Format string for image filename" to "Scans\*.jpg" I have tried specifying an absolte path like "D:\Music\Eddi\Eddi - 2016 - Challenge\CD1\Scans\*.jpg" or relative path as in "%\_parent\_directory%\Scans\*.jpg" but that all to no avail.

I have also used another column and imported the absolute path of the image file from text into it and then set the Action to read from that column but the error remains the same. There are no special characters anywhere as far as I can see; and I have full admin rights...

I have no problems having to run a different action for all albums containing multiple subfolders, like CD1, CD2, etc but can somebody please provide me with a solution?

Thanks in advance,  
Eddi

---

<div class="post-metadata">

### Author: ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)
#### Post date: [January 30, 2016, 1:38am UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/2 "2016-01-30T01:38:10Z")

</div>

For albums containing multiple sub-folders, try this format string:

```
$regexp(%_path%,($repeat(.+\\\\,$sub($folderdepth(%_path%),1)))(.+)(\\\\.+),$1Scans\)*.jpg

```

Just to be clear, I've assumed your problematic folder structure is this:

- For cover files: "D:\Music\Eddi\Eddi - 2016 - Challenge\Scans"
- For audio files: "D:\Music\Eddi\Eddi - 2016 - Challenge\CD1"

---

<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: [January 30, 2016, 9:30am UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/3 "2016-01-30T09:30:50Z")

</div>

> [@Eddi](#):
>
> ...  
> I have no problems having to run a different action for all albums containing multiple subfolders, like CD1, CD2, etc but can somebody please provide me with a solution?  
> ...

I think that this is more or less a one-off treatment of your files.  
So I would use filters to cater for the different subfolders  
e.g.  
%\_path% HAS CD1  
and then use CD1\*.jpg  
as import file name.  
and then  
%\_path% HAS scans  
with  
scans\*.jpg  
and so on.  
Finally, I would use a filter to see if all files have got a cover  
%\_covers% MISSING  
should ideally produce an empty list.  
But it could just a well be that you find some folders with other names.

---

<div class="post-metadata">

### Author: ![eblankers](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@eblankers](https://community.mp3tag.de/u/eblankers)
#### Post date: [January 30, 2016, 10:04am UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/4 "2016-01-30T10:04:29Z")

</div>

[quote name='ryerman' post='88204']For albums containing multiple sub-folders, try this format string:

```
$regexp(%_path%,($repeat(.+\\\\,$sub($folderdepth(%_path%),1)))(.+)(\\\\.+),$1Scans\)*.jpg

```

@ryerman - your solution works like a charm! There might be some additional challenges with slightly different directory structures, but I think I'll manage from here for now. Many thanks, this is brilliant!

---

<div class="post-metadata">

### Author: ![eblankers](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@eblankers](https://community.mp3tag.de/u/eblankers)
#### Post date: [January 30, 2016, 10:13am UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/5 "2016-01-30T10:13:27Z")

</div>

[quote name='ohrenkino' post='88208']  
So I would use filters to cater for the different subfolders  
e.g.  
%\_path% HAS CD1  
and then use CD1\*.jpg  
as import file name.

@ohrenkino, thanks for your reply, as well. I can surely give it a try, but I do believe it will not work, because the Scans folder is not in the CD1 directory

It will return something like  
Import cover from file "CD1\ \*.jpg" (Front Cover): File D:\MUSIC\Eddi\Eddi - 2016 - Challenge **\CD1\CD1\</b\> \*.jpg cannot be accessed.**

---

<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: [January 30, 2016, 10:25am UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/6 "2016-01-30T10:25:41Z")

</div>

> [@Eddi](#):
>
> ... add the album covers. ... I certainly do not want to restructure my MUSIC directory. ... please provide me with a solution ...

**Action #1: "Import cover from file" Import cover as: Front Cover Formatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)'Scans\*\_1.jpg' Action #2: "Import cover from file" Import cover as: Back Cover Formatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)'Scans\*\_2.jpg'**

Testfiles ...  
[20160130.Eddi.zip](https://community.mp3tag.de/uploads/default/original/2X/7/7ab80cc08ede3bf85703988e2291b210bb493950.zip) (53.3 KB)

DD.20160130.1225.CET

[20160130.Eddi.zip](https://community.mp3tag.de/uploads/default/original/2X/7/7ab80cc08ede3bf85703988e2291b210bb493950.zip) (53.3 KB)

---

<div class="post-metadata">

### Author: ![eblankers](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@eblankers](https://community.mp3tag.de/u/eblankers)
#### Post date: [January 30, 2016, 12:41pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/7 "2016-01-30T12:41:20Z")

</div>

@DetlevD, THANKS a lot for your solution, as well. In fact, it is even better in the sense that it can be executed on both folders regardless of whether these contain a CD1 or CD2 subfolder.

I have noticed that Mp3tag defaults to the last cover that was assigned, so I will probably change the oprder of the actions and first assign the back cover and then the front cover, so that the front covers are displayed within the application.

---

<div class="post-metadata">

### Author: ![eblankers](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@eblankers](https://community.mp3tag.de/u/eblankers)
#### Post date: [January 30, 2016, 9:04pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/8 "2016-01-30T21:04:30Z")

</div>

[quote name='DetlevD' post='88213']  
[size=1][font="Courier New"][b]Action #1: "Import cover from file"

Import cover as: Front CoverFormatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)'Scans\*\_1.jpg'

@DetlevD, or anybody else, do you happen to know of a way to grab the image files from a 'Scans' directory that is not one but two levels higher up than the audio file; from the great grand parent folder so to speak?

For example, in the following scenario where I store .flac files in a separate folder:

D:\MUSIC\

|  
---Eddi

```
\---Eddi - 2016 - Challenge2
    +---FLAC (=%_parent_directory%)
    | +---CD1 (=%_directory%)
    | | 01 - Intro.flac (=%_path%)
    | | 02 - Chorus.flac
    | |       
    | \---CD2
    | 01 - Solo.flac
    | 02 - Outro.flac
    |           
    \---Scans
            NoCover_1.jpg
            NoCover_2.jpg 

```

Thanks!

---

<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: [January 30, 2016, 9:27pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/9 "2016-01-30T21:27:03Z")

</div>

You can always use an absolute path.

The syntax to address the parent directory is ..  
so ....\*.jpg  
addresses files 2 directories up.  
I do not now how many cases you have ... it might be easier to treat the files individually.

---

<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: [January 31, 2016, 8:50am UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/10 "2016-01-31T08:50:57Z")

</div>

> [@Eddi](#):
>
> ... @DetlevD, or anybody else, do you happen to know of a way to grab the image files from a 'Scans' directory that is not one but two levels higher up than the audio file; from the great grand parent folder so to speak? ...

You can use a slightly changed version of my proposal from above ...  
by applying a relative path component.

**If standard folder ... Action "Import cover from file" Import cover as: Front Cover Formatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)'Scans\*\_1.jpg'** 

If folder "FLAC" exist ...

 Action "Import cover from file" Import cover as: Front Cover Formatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)'..\Scans\*\_1.jpg' 

Both cases merged into one action ...

 Action "Import cover from file" Import cover as: Front Cover Formatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)$ifgreater($strstr(%\_folderpath%,'\FLAC\'),0,'..\',)'Scans\*\_1.jpg' 

... or a little bit more safe ...

 Formatstring: $regexp(%\_folderpath%,%\_directory%'\\\\$',)$ifgreater($strstr(%\_folderpath%,'\FLAC\'%\_directory%),0,'..\',)'Scans\*\_1.jpg'

DD.20160131.1125.CET

How to address a folder by it's relative pathname ...

**%\_folderpath% \<== 'C:\D1\D2\D3\' %\_folderpath%$repeat('..\',0) ==\> 'C:\D1\D2\D3\' %\_folderpath%$repeat('..\',1) ==\> 'C:\D1\D2\' %\_folderpath%$repeat('..\',2) ==\> 'C:\D1\' %\_folderpath%$repeat('..\',3) ==\> 'C:\' %\_folderpath%$repeat('..\',$sub($folderdepth(%\_folderpath%),0)) ==\> 'C:\' %\_folderpath%$repeat('..\',$sub($folderdepth(%\_folderpath%),1)) ==\> 'C:\D1\' %\_folderpath%$repeat('..\',$sub($folderdepth(%\_folderpath%),2)) ==\> 'C:\D1\D2\' %\_folderpath%$repeat('..\',$sub($folderdepth(%\_folderpath%),3)) ==\> 'C:\D1\D2\D3\'**

DD.20160131.1605.CET

---

<div class="post-metadata">

### Author: ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)
#### Post date: [January 31, 2016, 12:17pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/11 "2016-01-31T12:17:22Z")

</div>

> [@Eddi](#):
>
> @DetlevD, or anybody else, do you happen to know of a way to grab the image files from a 'Scans' directory that is not one but two levels higher up than the audio file; from the great grand parent folder so to speak?

Here is a generalized format string. Notice the variable X.

$regexp(%\_path%,($repeat(.+\\,$sub($folderdepth(%\_path%),X))).+$repeat(\\.+,X),$1)

It can be adjusted to return the path to any directory in a files path.  
Replace the variable X (used in two positions) with the number corresponding to the directory of interest.  
0 - directory  
1 - parent directory  
2 - grandparent directory  
3 - great-grandparent directory  
4 - great-great-grandparent directory  
and so on...

The string will return the path to the chosen directory, with a trailing back-slash.

If X = $folderdepth(%\_path%), the drive letter is returned.  
If X = $folderdepth(%\_path%) + 1, $1 is not populated and nothing is returned.  
If X \> $folderdepth(%\_path%) + 1, the regex fails and %\_path% is returned.

---

<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: [January 31, 2016, 1:11pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/12 "2016-01-31T13:11:47Z")

</div>

> [@ryerman](#):
>
> ... If ... the regex fails and nothing is returned.

Note: A not matching $regexp() returns the full input string.

DD.20160131.1511.CET

---

<div class="post-metadata">

### Author: ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)
#### Post date: [January 31, 2016, 1:19pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/13 "2016-01-31T13:19:46Z")

</div>

> [@DetlevD](#):
>
> Note: A not matching $regexp() returns the full input string.
> 
> DD.20160131.1511.CET

Thanks for the correction.  
~~Is it accurate to say "If X is greater than $folderdepth(%\_path%), $1 is not populated and nothing is returned."?~~  
Sorry, ignore that question.  
I'll edit my previous post.

---

<div class="post-metadata">

### Author: ![eblankers](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@eblankers](https://community.mp3tag.de/u/eblankers)
#### Post date: [February 4, 2016, 8:33pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/14 "2016-02-04T20:33:46Z")

</div>

> [@ryerman](#):
>
> Thanks for the correction.

> [@DetlevD](#):
>
> Note: A not matching $regexp() returns the full input string.
> 
> DD.20160131.1511.CET

Apologies for the late reply; thank you all very much for the great help and thorough explanations! It's working beautifully 🙂

---

<div class="post-metadata">

### Author: ![mi6](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/919ad9/32.png) [@mi6](https://community.mp3tag.de/u/mi6)
#### Post date: [February 2, 2021, 2:26pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/15 "2021-02-02T14:26:25Z")

</div>

For me, a non-regexp solution for covers in subfolders of a folder with mp3 files is to import using the following string in an action:

`Covers\*front*.*p*g`

This would import front.jpg or front.jpeg or front.png from a subfolder Covers.

 ![image](https://community.mp3tag.de/uploads/default/original/2X/9/9031da3ef5797b8f6da7cd668c942a51bf550dc2.png)

---

<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 2, 2021, 3:27pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/16 "2021-02-02T15:27:09Z")

</div>

This only works if you always have a subfolder called `\Covers` for every of your actual selected music files and all your pictures have the word "front" anywhere in its name.  
As an example:  
You will not import pictures like `First.jpg` or `1.jpg` or `Front.bmp`  
It will ignore a subfolder called `\Cover Art` or `\Scans`

---

<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:26pm UTC](https://community.mp3tag.de/t/challenge-to-import-cover-from-file/17601/17 "2026-02-09T12:26:04Z")

</div>


