[Batch-Script] Music-Folder-Artist-Thumb-Creator

Discussion in 'Tools and other software' started by bta489, April 2, 2017.

  1. bta489

    bta489 Portal Pro

    Joined:
    March 17, 2013
    Messages:
    112
    Likes Received:
    24
    Gender:
    Male
    Ratings:
    +49 / 0
    Home Country:
    Germany Germany
    Show System Specs
    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 (Text):
    1. 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 (Text):
    1. 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.

    Source-Code (open)

    Code (Winbatch):
    1. @echo off
    2.  
    3. :: Add the Path to your MediaPortal-Thumbsfolder (no backslash at the end)
    4. set THUMBSFOLDER=
    5. :: Add the Path to your Music-Folder  (no backslash at the end)
    6. set MUSICFOLDER=
    7.  
    8. :: =======================================================================================
    9. echo Music-Folder-Artist-Thumb-Creator (v1.0)
    10. echo -- by bta489 ---------------------------
    11. echo.
    12.  
    13.  
    14. if NOT DEFINED THUMBFOLDER (
    15.     set THUMBSFOLDER=C:\ProgramData\Team MediaPortal\MediaPortal\Thumbs\Music\Artists
    16.     )
    17.    
    18. echo.
    19.  
    20. if NOT EXIST "%THUMBSFOLDER%" (
    21.     echo Error!
    22.     echo The specified Thumb-folder appears to not exist. Please check.
    23.     pause
    24.     goto :eof
    25. )
    26. if NOT DEFINED MUSICFOLDER (
    27.     echo No Music-Folder specified, using "%cd%" instead.
    28.     set /p NOFOLDER="Continue? (Y/N) "
    29.     )
    30.    
    31. IF /I "%NOFOLDER%"=="y" (
    32.     set MUSICFOLDER=%cd%
    33.     )
    34. IF /I "%NOFOLDER%"=="n" (
    35.     echo Cancel Operation
    36.     goto :eof
    37.     )
    38.    
    39. if NOT EXIST "%MUSICFOLDER%" (
    40.     echo Error!
    41.     echo The specified Music-folder appears to not exist. Please check.
    42.     pause
    43.     goto :eof
    44. )  
    45.    
    46. echo.
    47. set /p INPUT="Hide all Thumbs? (Y/N) "
    48.  
    49.  
    50. echo Start at %time% > %MUSICFOLDER%\log.txt
    51. echo. >> %MUSICFOLDER%\log.txt
    52.  
    53. set /a NUMBEROFFOLDERS=0
    54. set /a NUMBERIDLE=0
    55. set /a NUMBERCOPIED=0
    56. set /a NUMBERUNAVIALABLE=0
    57.  
    58. FOR /d %%a IN ("%MUSICFOLDER%\*") DO (
    59.     set /a NUMBERFOLDERS+=1
    60.     IF NOT EXIST "%%a\folder.jpg" (
    61.         IF EXIST "%THUMBSFOLDER%\%%~nxaL.jpg" (
    62.             copy "%THUMBSFOLDER%\%%~nxaL.jpg" "%%a\folder.jpg"
    63.             IF /I "%INPUT%"=="y" attrib +h "%%a\folder.jpg"
    64.            
    65.             echo OK -- Artist: "%%~nxa"
    66.             echo Artist: "%%~nxa" >> %MUSICFOLDER%\log.txt
    67.             echo Result: Thumb successfully copied>> %MUSICFOLDER%\log.txt
    68.             echo. >> %MUSICFOLDER%\log.txt
    69.             set /a NUMBERCOPIED+=1
    70.         ) ELSE (
    71.             echo ?? -- Artist: "%%~nxa"
    72.        
    73.             echo Artist: "%%~nxa" >> %MUSICFOLDER%\log.txt
    74.             echo Result: No Thumb available>> %MUSICFOLDER%\log.txt
    75.             echo. >> %MUSICFOLDER%\log.txt
    76.             set /a NUMBERUNAVIALABLE+=1
    77.         )
    78.     ) ELSE (
    79.         IF /I "%INPUT%"=="y" attrib +h "%%a\folder.jpg"
    80.         echo OK -- Artist: "%%~nxa"
    81.        
    82.         echo Artist: "%%~nxa" >> %MUSICFOLDER%\log.txt
    83.         echo Result: Thumb already exists >> %MUSICFOLDER%\log.txt
    84.         echo. >> %MUSICFOLDER%\log.txt
    85.         set /a NUMBERIDLE+=1
    86.     )
    87. )
    88.  
    89. echo END at %time% >> %MUSICFOLDER%\log.txt
    90. echo. >> %MUSICFOLDER%\log.txt
    91. echo Folders processed: %NUMBERFOLDERS% >> %MUSICFOLDER%\log.txt
    92. echo Thumbs copied: %NUMBERCOPIED% >> %MUSICFOLDER%\log.txt
    93. echo Thumbs already present: %NUMBERIDLE% >> %MUSICFOLDER%\log.txt
    94. echo Thumbs not found: %NUMBERUNAVIALABLE% >> %MUSICFOLDER%\log.txt
    95.  
    96. echo.
    97. echo %NUMBERFOLDERS% Folders processed
    98. echo -- %NUMBERCOPIED% Thumbs created
    99. echo -- %NUMBERIDLE% already existed
    100. echo -- %NUMBERUNAVIALABLE% were not found in Thumbs-Folder
    101.  
    102. pause
     

    Attached Files:

    Last edited: April 2, 2017
    • Thank You! Thank You! x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. azzuro
    • Team MediaPortal

    azzuro Test Group

    Joined:
    May 10, 2007
    Messages:
    8,280
    Likes Received:
    2,353
    Occupation:
    technician HVAC
    Location:
    France - IDF
    Ratings:
    +3,986 / 13
    Home Country:
    France France
    Show System Specs
  4. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,509
    Likes Received:
    2,566
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,497 / 29
    Home Country:
    Ukraine Ukraine
    Show System Specs
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!