# batch file to check for missing covers

**URL:** https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448
**Category:** General Discussion
**Created:** [January 15, 2011, 4:59pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448 "2011-01-15T16:59:04Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 15, 2011, 4:59pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/1 "2011-01-15T16:59:04Z")

</div>

I want to use batch files to check my folders for missing covers and create a playlist of all these folders.

For a simple folder tree with no sub folders

root  
-album1  
-album2  
...

I figured out this code:

```
@echo off
IF EXIST no_covers.m3u DEL no_covers.m3u
FOR /D %%A IN (*.*) DO (
IF NOT EXIST %%~fA\folder.jpg echo %%~fA%>>no_covers.m3u)

```

Now I need a batch file that searches all sub folders and only checks for folder.jpg files in folders that also contain audio files because I also have some empty folders in the folder tree.

root  
-artist1  
---album1  
-artist2  
--album1  
--album2

Can anyone help?

---

<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: [January 15, 2011, 7:20pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/2 "2011-01-15T19:20:52Z")

</div>

Maybe you could use FOR /R (recursive) loop?  
But the tricky thing will be the combination with audio files ![:huh:](https://community.mp3tag.de/uploads/default/original/1X/f15ee73c0fd9ec3b0db7481f0558638f8ee224ce.gif ":huh:")

---

<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 15, 2011, 8:04pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/3 "2011-01-15T20:04:40Z")

</div>

> [@dano](#):
>
> ...Can anyone help?

Anyway no mighty help, but maybe a direction to go ...

```
@ECHO OFF
SET ROOT=M:\MUSIC
SETLOCAL DisableDelayedExpansion

FOR /F "usebackq tokens=*" %%D IN (`DIR "%ROOT%" /B/AD/S/-P`) DO (
   @ECHO."%%D"
   DIR "%%D" /B/A/-P >NUL. 2>&1
   IF ERRORLEVEL 1 (
      ECHO ###Folder "%%D" is empty
   )
)

```

SETLOCAL DisableDelayedExpansion  
... is set, because a foldername with an exclamation mark "!" otherwise is not recognized.

Foldername "Fehlfarben - 2006 - 26 1⁄2" still cannot be handled and will be reported as empty.  
Note: The "⁄" is not a normal slash, but a unicode character (hex:E2 81 84).

DD.20110115.2206.CET

If you like PowerShell, then you may look there:  
[http://technet.microsoft.com/en-us/library/ff730953.aspx](http://technet.microsoft.com/en-us/library/ff730953.aspx)  
[http://technet.microsoft.com/en-us/library/ee692944.aspx](http://technet.microsoft.com/en-us/library/ee692944.aspx)

---

<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 16, 2011, 11:40am UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/4 "2011-01-16T11:40:09Z")

</div>

> [@dano](#):
>
> ... Can anyone help?

Dano, see attached command file.  
~~Attachment 3574 not found.~~  
DD.2011011.1346.CET

Edit. Attachment removed.  
DD.20110117.1747.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 16, 2011, 2:40pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/5 "2011-01-16T14:40:12Z")

</div>

Thanks Detlev.  
But I think I sent you in the wrong direction with the empty folders.  
Actually I don't need to check for empty folders.  
What I need is  
_check in every folder if there are any mp3 or flac files and if it is true check if folder.jpg is missing_

I tried something inside the loop which seems to work to some extent.

```
DIR "*.mp3" >NUL 2>&1
   IF ERRORLEVEL 1 (
      IF NOT EXIST "%%~fD\\%FS%" echo %%~fD%>>no_covers.m3u
   )

```

But it gives false positives on empty folders.

And do you know how to set **root** to the folder where the cmd file is started in?

---

<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 16, 2011, 4:06pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/6 "2011-01-16T16:06:04Z")

</div>

> [@dano](#):
>
> ... And do you know how to set **root** to the folder where the cmd file is started in?

%0 is the filepath of the cmd file, so ....

@ECHO OFF  
ECHO This cmd's filepath:  
ECHO %0  
ECHO This cmd's home folder:  
ECHO %~dp0  
ECHO The root folder:  
SET ROOT=%~dp0  
ECHO %ROOT%  
PAUSE

DD.20110116.1810.CET

---

<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 16, 2011, 7:26pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/7 "2011-01-16T19:26:50Z")

</div>

> [@dano](#):
>
> ... What I need is _check in every folder if there are any mp3 or flac files and if it is true check if folder.jpg is missing_...

It would have been easier to solve the problem by using a more handy scripting language.  
Dano, see attached command file.  
DD.20110116.2135.CET

Sorry, I did forget to include the most important case:  
The folder with music files but without folder.jpg.

~~Attachment 3580 not found.~~

DD.20110116.2300.CET

Edit. Attachment removed.  
DD.20110117.1747.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 16, 2011, 7:55pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/8 "2011-01-16T19:55:25Z")

</div>

The solution I found:

```
DIR "%%~fD\*.mp3">NUL 2>&1
    IF NOT ERRORLEVEL 1 (        
      IF NOT EXIST "%%~fD\\%FS%" ECHO %%~fD>>%FM%
   )

```

About the root folder, I was looking for %CD%  
_SET ROOT=%CD%_ is what I use now so I can start it from TC

> [@](#):
>
> It would have been easier to solve the problem by using a more handy scripting language.  
> Dano, see attached command file.

I was hoping it was solvable with DOS although it seems tricky. I don't know many other scripting languages.

Well thank you for the great help, I will also look at your last cmd file.

---

<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 16, 2011, 9:04pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/9 "2011-01-16T21:04:57Z")

</div>

**Check.Folder.jpg.cmd**  
New version, see post #7.  
[batch file to check for missing covers](https://community.mp3tag.de/t/11448/7)

DD.20110116.2307.CET

---

<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 17, 2011, 8:34am UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/10 "2011-01-17T08:34:18Z")

</div>

**Check.Folder.jpg.cmd**  
New version here.  
Hopefully my last approach.  
~~Attachment 3582 not found.~~  
DD.20110117.1040.CET

Edit. Attachment removed.  
DD.20110117.1745.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 17, 2011, 9:24am UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/11 "2011-01-17T09:24:11Z")

</div>

Very nice again, one thing. These vars need quotes:  
SET RFA=%HF%%RFA%  
SET RMN=%HF%%RMN%  
SET RPY=%HF%%RPY%  
SET RPN=%HF%%RPN%

Also SET MP3TAG= is a problem when %programfiles% contains spaces.

There's something wrong with the unicode conversion.

---

<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 17, 2011, 3:43pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/12 "2011-01-17T15:43:37Z")

</div>

> [@dano](#):
>
> Very nice again ... There's something wrong with the unicode conversion.

Thanks for reporting back.

Regarding the usage of codepages and unicode support see also these interesting articles from user Moonbase:  
[Feature Request: Unicode Support for Export to Batch Files](https://community.mp3tag.de/t/7321/1)  
[HowTo: Einfache Text-Liste aller Bands und Alben](https://community.mp3tag.de/t/7403/1)  
[Feature Request: Disable "DOS&nbsp;Box" while running a "Tool"?](https://community.mp3tag.de/t/7313/1)

There is a new code version attached.  
**Check.Folder.jpg.cmd**  
~~Attachment 3589 not found.~~

DD.20110117.1930.CET

Edit. Attachment removed.  
DD.20110118.1609.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 18, 2011, 8:56am UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/13 "2011-01-18T08:56:42Z")

</div>

Somehow all the unicode report files only get þ as BOM so they can't be displayed correctly.

---

<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 18, 2011, 1:04pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/14 "2011-01-18T13:04:27Z")

</div>

Huh, how that? Sorry for the invonvenience.  
I will download the uploaded file for myself and try to detect what happened with the text file.

There is a zip file attached containing the command file.  
I have added a notice into the command file how to create BOM characters via keyboard.  
Please try this.  
~~Attachment 3590 not found.~~  
Note: It is possible that Avira reports a false alarm for this cmd file in the zip file.  
I've just reported the false alarm to Avira.

The same command file in a 7-zip file is ok for Avira.  
But sadly the Forum does not allow to upload a 7-zip file.  
Proposal: Upload should be opended for .7z files too.

DD.20110118.1514.CET

Edit. Attachment removed.  
DD.20110118.1609.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 18, 2011, 1:32pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/15 "2011-01-18T13:32:14Z")

</div>

The zip version also fails. It had already happened in earlier versions.

---

<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 18, 2011, 2:07pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/16 "2011-01-18T14:07:51Z")

</div>

I cannot believe this!

Are you able to create these characters with the keyboard numpad on the DOS commandline ?  
BOM marker for UTF-16LE:  
hex:FF=[Alt]+Numpad 00255=ÿ  
hex:FE=[Alt]+Numpad 00254=þ

If not, then there will be some other way to provide a 2-Byte BOM-only file.  
I will think over.  
What DOS codepage do you use?

There is a new code version attached.  
**Check.Folder.jpg.cmd**  
~~Attachment 3591 not found.~~

DD.20110118.1608.CET

Edit. Attachment removed.  
DD.20110118.1657.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 18, 2011, 2:33pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/17 "2011-01-18T14:33:57Z")

</div>

Default codepage is 850  
Alt+0255/0254 works

When I type chcp 1252 in the DOS box Alt+0255/0254 give different results.

---

<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 18, 2011, 2:57pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/18 "2011-01-18T14:57:08Z")

</div>

> [@dano](#):
>
> Default codepage is 850  
> Alt+0255/0254 works  
> When I type chcp 1252 in the DOS box Alt+0255/0254 give different results.

Hmm, yes, indeed. I have made sure that CP 850 is used when creating the BOM helper file.

Here is a new code version attached.  
Check.Folder.jpg.cmd  
~~Attachment 3592 not found.~~  
DD.20110118.1657.CET

Edit. Attachment removed.  
DD.20110127.1825.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 18, 2011, 3:12pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/19 "2011-01-18T15:12:25Z")

</div>

Same issue.  
Deltev it seems you must do the opposite, use codepage 1252 to create the unicode files.  
In cp 850 these chars have different codepoints (maybe that's the reason, I don't really know)  
At least it works for me.

---

<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 18, 2011, 4:27pm UTC](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448/20 "2011-01-18T16:27:29Z")

</div>

> [@dano](#):
>
> Same issue.  
> Deltev you must do the opposite, use codepage 1252 to create the unicode files.  
> In cp 850 these chars have different codepoints (maybe that's the reason, I don't really know)  
> At least it works for me.

Now I know, I should have used a Windows oriented script language from the first step.  
Using olde DOS and it's codepages it is more tricky than I have ever expected.  
And it seems that you are right that I've mangled the code points and the code pages and what ever more.  
I will look into again, but at first I need a break.  
Stay tuned.

DD.20110118.1825.CET

[Next page](https://community.mp3tag.de/t/batch-file-to-check-for-missing-covers/11448.md?page=2)
