Tools and other software Batch File Archive (1 Viewer)

Lightning303

MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Hey,
    im running small batch files on my HTPC on resume to handle stuff like backups and starting epg grabbing. I thought i would share them. Also i think its a nice idea to start a thread where everybody can share their batchfiles, so when somebody is looking for a specific solution they can find it here.

    I hope others will add their batch scripts here aswell, and i will then link them directly in this post. Please dont add them as files, but as text in code tags.

    Batch Scripts:
    • - Allow to start a batch file only once a day
      Code:
      @echo off 
      set LastDate=C:\LastDate.txt 
      set TempDate=C:\Date.tmp 
      
      if exist %TempDate% exit
            
      echo %date%>%TempDate%
      fc %TempDate% %LastDate% >nul
      if %ERRORLEVEL%==1 goto NewDay
      goto End
            
      :NewDay 
      :: What to do
            
      :End
      move %TempDate% %LastDate%
      exit
    • - Backup Files (e.g. Mediaportal Databases)
      Code:
      :: Backing up everything from D:, and keeping the backups for 7 days.
      xcopy D:\*.* D:\temp\ /y/q
      FOR /F "tokens=1,2 delims=:" %%d IN ('date /t') DO set dat=%%d
      FOR /F "tokens=1,2 delims=:" %%i IN ('time /t') DO set zeit=%%i-%%j
      rename D:\temp "Backup %dat%%zeit%"
      FOR /F "skip=7 tokens=*" %%c IN ('DIR /O-D /B D:\"Backup *"') DO (rd D:\"%%c" /s/q)
    • - Start WebGrab++ and keep TVServer from going crazy
      Code:
      "C:\Program Files (x86)\ServerCare\WebGrab+Plus\WebGrab+Plus.exe"
      xcopy "C:\ProgramData\Team MediaPortal\MediaPortal TV Server\xmltv\temp.xml" "C:\ProgramData\Team MediaPortal\MediaPortal TV Server\xmltv\tvguide.xml" /Y
    • Comskip by @eisblock
    • Copy ClearArt and ClearLogos to Mediaportal folders by @ixdvc
    • Backup local fanart by @ixdvc
     
    Last edited:

    eisblock

    Portal Pro
    March 19, 2010
    98
    13
    comskip.4.bat
    Code:
    @ECHO OFF
    
    SET CS_PATH=C:\Programme\Comskip
    SET CS_LOGO=
    SET CS_DEF_INI=--ini="%CS_PATH%\Channel_ini\_default.ini"
    
    
    CALL :comskipstart %1 %2
    GOTO :ende
    
    
    :comskipstart
    :: ini festlegen
        IF EXIST "%CS_PATH%\Channel_ini\%~2.ini" (
            SET CS_DEF_INI=--ini="%CS_PATH%\Channel_ini\%~2.ini"
        )
       
    :: Logo festlegen, falls gewünscht
    REM     IF EXIST "%CS_PATH%\Channel_logo\%~2.logo.txt" (
    REM         SET CS_LOGO=--logo="%CS_PATH%\Channel_logo\%~2.logo.txt"
    REM     )
    
    :: Log Ausgabe   
        ECHO.FILE....: %1 >"%~dpn1.bat.log"
        ECHO.CHANNL..: %2    >>"%~dpn1.bat.log"
        ECHO.INI.....: %CS_DEF_INI% >>"%~dpn1.bat.log"
        ECHO.LOGO....: %CS_LOGO% >>"%~dpn1.bat.log"
        ECHO.........: comskip.4.bat, startet nun comskip.exe :........ >>"%~dpn1.bat.log"
    
    
    :: Kopiere Timeshift
    ::    START /MIN  %CS_PATH%\CopyTimeshift.bat "%~1"
       
    :: execute comskip --debugwindow .... START
        %CS_PATH%\comskip.exe --ts %CS_DEF_INI% %CS_LOGO% %1
    
    GOTO :ende
    
    :ende
     

    ixdvc

    Portal Pro
    May 26, 2009
    227
    39
    Home Country
    Germany Germany
    I use Ember Media Manager to scrape nfos and fanart for my TV shows. I also like to download clearart and clearlogos directly from fanart.tv to select the ones I like best and save them to the show folders. Then the XBMC clients are able to find them.
    So I wrote a batch file to copy those cleararts and clearlogos to the MePo thumbs folder. The files have to be renamed to the show id which is read from tvshow.nfo in the show folder.

    Make a backup of your current cleararts and clearlogos from
    Code:
    C:\ProgramData\Team MediaPortal\MediaPortal\thumbs\ClearArt\
    C:\ProgramData\Team MediaPortal\MediaPortal\thumbs\ClearLogo\
    C:\ProgramData\Team MediaPortal\MediaPortal\thumbs\TVSeries\ClearArt\
    C:\ProgramData\Team MediaPortal\MediaPortal\thumbs\TVSeries\ClearLogo\
    as those are overwritten without question.
    Code:
    @echo off
    set thumbspath=C:\ProgramData\Team MediaPortal\MediaPortal\thumbs
    
    IF exist "%thumbspath%\ClearArt\Series" ( echo %thumbspath%\ClearArt\Series exists ) ELSE ( mkdir "%thumbspath%\ClearArt\Series" && echo %thumbspath%\ClearArt\Series created )
    IF exist "%thumbspath%\ClearLogo\Series" ( echo %thumbspath%\ClearLogo\Series exists ) ELSE ( mkdir "%thumbspath%\ClearLogo\Series" && echo %thumbspath%\ClearLogo\Series created )
    IF exist "%thumbspath%\TVSeries\ClearArt\FullSize" ( echo %thumbspath%\TVSeries\ClearArt\FullSize exists ) ELSE ( mkdir "%thumbspath%\TVSeries\ClearArt\FullSize" && echo %thumbspath%\TVSeries\ClearArt\FullSize created )
    IF exist "%thumbspath%\TVSeries\ClearLogo\FullSize" ( echo %thumbspath%\TVSeries\ClearLogo\FullSize exists ) ELSE ( mkdir "%thumbspath%\TVSeries\ClearLogo\FullSize" && echo %thumbspath%\TVSeries\ClearLogo\FullSize created )
    
    set seriesfolder=%~dp0
    
    for /D %%G in (*) do (
        pushd %%G
        set series=%%G
        REM if %cd%==%seriesfolder% goto :eof
        call :getid
    )
    
    :getid
    FOR /F "tokens=1-2 delims=<>, " %%I in (tvshow.nfo) do (
        REM echo %%I
        if %%I==id (
            set tvshowid=%%J
            goto :copying
        )
    )
    
    :copying
    echo ID for %series% is %tvshowid%. Copying images.
    copy "clearart.png" "%thumbspath%\clearart\Series\%tvshowid%.png"
    copy "logo.png" "%thumbspath%\clearlogo\Series\%tvshowid%.png"
    copy "clearart.png" "%thumbspath%\TVSeries\ClearArt\FullSize\%tvshowid%.png"
    copy "logo.png" "%thumbspath%\TVSeries\ClearLogo\FullSize\%tvshowid%.png"
    popd
    
    :eof
    cd %~dp0
    And I have another batch file to backup my local fanart (all png and jpg files from the show folder). The backup folder can be set in the second line:
    Code:
    @echo off
    set backuppath=C:\fanartbkp
    
    IF exist "%backuppath%" ( echo %backuppath% exists ) ELSE ( mkdir "%backuppath%" && echo %backuppath% created )
    
    set seriesfolder=%~dp0
    
    for /D %%G in (*) do (
        pushd %%G
        set series=%%G
        REM if %cd%==%seriesfolder% goto :eof
        call :copying
    )
    
    :copying
    echo Copying images for %series%.
    IF exist "%backuppath%\%series%\" ( echo %backuppath%\%series%\ exists ) ELSE ( mkdir "%backuppath%\%series%\" && echo %backuppath%\%series%\ created )
    copy "*.png" "%backuppath%\%series%\"
    copy "*.jpg" "%backuppath%\%series%\"
    popd
    
    :eof
    cd %~dp0
    Both batch files are meant to be run from your base TV show path, it should be like that:
    Code:
    TV Shows
    |----TV Show 1
    | |--clearart.png
    | |--logo.png
    |----TV Show 2
    | |--files
    |----fanart.bat
    |----fanart-backup.bat
    And those batch files do not like to be run from UNC paths. So your folder has to be mounted as a network drive at least temporarily.
     

    Users who are viewing this thread

    Top Bottom