Tools and other software [Batch-Script] Music-Folder-Artist-Thumb-Creator (1 Viewer)

bta489

Portal Pro
March 17, 2013
168
92
Home Country
Germany Germany
Hi there,

I created a little Batch-Script that I'd like to share. It scans your Music-Folder and creates Folder thumbs for your Artists-Folders using your Mediaportal Thumbs-Folder. Additionally, you can choose if all thumbnails should be set as hidden.

So your Music Folder that may look like this
Before.jpg
might look like this
After.jpg

If the folder already contains a "folder.jpg"-File, it will be left unchanged. A log is created to keep track what the script did.

Instructions:
Save the .bat in your Music-Folder, run it and follow the instructions.
If you are using a custom Thumbs-Folder (other than "C:\ProgramData\Team MediaPortal\MediaPortal\Thumbs\Music\Artists") set it in the beginning of the .bat-File after "THUMBSFOLDER=" like this:
Code:
set THUMBSFOLDER=Q:\Some random\custom\path
.
You can also specify the Music-Folder in the .bat-File, so you can save the File somewhere else, in a similar fashion:
Code:
set MUSICFOLDER=M:\My Music Folder

For those two options please make sure that the path does not end with a backslash and is not encased in quotation-marks.

Code:
@echo off

:: Add the Path to your MediaPortal-Thumbsfolder (no backslash at the end)
set THUMBSFOLDER=
:: Add the Path to your Music-Folder  (no backslash at the end)
set MUSICFOLDER=

:: =======================================================================================
echo Music-Folder-Artist-Thumb-Creator (v1.0)
echo -- by bta489 ---------------------------
echo.


if NOT DEFINED THUMBFOLDER (
    set THUMBSFOLDER=C:\ProgramData\Team MediaPortal\MediaPortal\Thumbs\Music\Artists
    )
   
echo.

if NOT EXIST "%THUMBSFOLDER%" (
    echo Error!
    echo The specified Thumb-folder appears to not exist. Please check.
    pause
    goto :eof
)
if NOT DEFINED MUSICFOLDER (
    echo No Music-Folder specified, using "%cd%" instead.
    set /p NOFOLDER="Continue? (Y/N) "
    )
   
IF /I "%NOFOLDER%"=="y" (
    set MUSICFOLDER=%cd%
    )
IF /I "%NOFOLDER%"=="n" (
    echo Cancel Operation
    goto :eof
    )
   
if NOT EXIST "%MUSICFOLDER%" (
    echo Error!
    echo The specified Music-folder appears to not exist. Please check.
    pause
    goto :eof
)   
   
echo.
set /p INPUT="Hide all Thumbs? (Y/N) "


echo Start at %time% > %MUSICFOLDER%\log.txt
echo. >> %MUSICFOLDER%\log.txt

set /a NUMBEROFFOLDERS=0
set /a NUMBERIDLE=0
set /a NUMBERCOPIED=0
set /a NUMBERUNAVIALABLE=0

FOR /d %%a IN ("%MUSICFOLDER%\*") DO (
    set /a NUMBERFOLDERS+=1
    IF NOT EXIST "%%a\folder.jpg" (
        IF EXIST "%THUMBSFOLDER%\%%~nxaL.jpg" (
            copy "%THUMBSFOLDER%\%%~nxaL.jpg" "%%a\folder.jpg"
            IF /I "%INPUT%"=="y" attrib +h "%%a\folder.jpg"
           
            echo OK -- Artist: "%%~nxa"
            echo Artist: "%%~nxa" >> %MUSICFOLDER%\log.txt
            echo Result: Thumb successfully copied>> %MUSICFOLDER%\log.txt
            echo. >> %MUSICFOLDER%\log.txt
            set /a NUMBERCOPIED+=1
        ) ELSE (
            echo ?? -- Artist: "%%~nxa"
       
            echo Artist: "%%~nxa" >> %MUSICFOLDER%\log.txt
            echo Result: No Thumb available>> %MUSICFOLDER%\log.txt
            echo. >> %MUSICFOLDER%\log.txt
            set /a NUMBERUNAVIALABLE+=1
        )
    ) ELSE (
        IF /I "%INPUT%"=="y" attrib +h "%%a\folder.jpg"
        echo OK -- Artist: "%%~nxa"
       
        echo Artist: "%%~nxa" >> %MUSICFOLDER%\log.txt
        echo Result: Thumb already exists >> %MUSICFOLDER%\log.txt
        echo. >> %MUSICFOLDER%\log.txt
        set /a NUMBERIDLE+=1
    )
)

echo END at %time% >> %MUSICFOLDER%\log.txt
echo. >> %MUSICFOLDER%\log.txt
echo Folders processed: %NUMBERFOLDERS% >> %MUSICFOLDER%\log.txt
echo Thumbs copied: %NUMBERCOPIED% >> %MUSICFOLDER%\log.txt
echo Thumbs already present: %NUMBERIDLE% >> %MUSICFOLDER%\log.txt
echo Thumbs not found: %NUMBERUNAVIALABLE% >> %MUSICFOLDER%\log.txt

echo.
echo %NUMBERFOLDERS% Folders processed
echo -- %NUMBERCOPIED% Thumbs created
echo -- %NUMBERIDLE% already existed
echo -- %NUMBERUNAVIALABLE% were not found in Thumbs-Folder

pause
 

Attachments

  • Music-Folder-Artist-Thumb-Creator_v1.zip
    1 KB
Last edited:

Users who are viewing this thread

Top Bottom