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.
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).
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?
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.
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.
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.
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.