Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- CLS
- SetLocal EnableDelayedExpansion
- REM Find TV Show Subdirectories
- IF EXIST %UserProfile%\Downloads\*hdtv* (
- FOR /F "tokens=* delims= " %%i IN ('DIR %UserProfile%\Downloads\*hdtv* /ad/b') DO (
- REM If there are rar files, unrar them into the downloads directory
- IF EXIST %%i\*.rar (
- "C:\%ProgramFiles%\7-Zip\7z" e "%%i\*.rar" -o%UserProfile%\Downloads
- ECHO.
- REM Error handling so that unextracted files aren't deleted
- CALL :Delete_on_Success !ERRORLEVEL! Archive Extraction %%i
- REM If no rars, move video files to the downloads directory
- ) ELSE (
- FOR %%j IN ( %%i\*.mkv %%i\*.avi) DO (
- IF %%j == "" (
- ECHO No Valid filetypes to Move
- ECHO.
- ) ELSE (
- MOVE /Y "%%i\%%j" %UserProfile%\Downloads
- ECHO.
- REM Error handling so that unmoved files aren't deleted
- CALL :Delete_on_Success !ERRORLEVEL! %%~xj Move %%i
- )
- )
- )
- )
- ) ELSE (
- ECHO No Subdirectories With Files to Move or Extract
- ECHO.
- )
- REM Convert MKV to MP4 for easier streaming and better device support
- IF EXIST *.mkv (
- FOR %%v IN (*.mkv) DO (
- REM Timestamp for progress report
- ECHO Begin converting %%v at !TIME!
- ECHO.
- REM Use FFMpeg to copy audio and video streams into an MP4 container (plus some switches for limited verbosity)
- "%ProgramFiles(x86)%\ffmpeg\bin\ffmpeg.exe" -loglevel error -v 1 -i "%%v" -vcodec copy -acodec copy "%%~nv.mp4" >NUL
- ECHO.
- REM Error handling so unconverted files are not deleted
- IF !ERRORLEVEL! NEQ 0 (
- ECHO Conversion Error on %%v
- ECHO.
- ) ELSE (
- REM Second timestamp for progress report
- ECHO %%~nv.mp4 complete at !time!
- ECHO.
- DEL "%%v"
- )
- )
- ) ELSE (
- ECHO No MKVs to Convert
- ECHO.
- )
- REM Check for files named with specific format to rename - e.g. Showname.s01e01.Showtitle.Resolution.Group.mp4
- IF EXIST *.s*.* (
- ECHO Renaming Files
- ECHO.
- "%ProgramFiles(x86)%\theRenamer\theRenamer" -fetch
- ) ELSE (
- ECHO Nothing to Rename
- ECHO.
- )
- PAUSE
- :Delete_on_Success
- REM Passed Arguments are ERRORLEVEL, filetype, action, directory
- IF %1 NEQ 0 (
- ECHO %2 %3 Error in %4
- ECHO.
- ) ELSE (
- CALL :Remove_Directory %4
- )
- GOTO :EOF
- :Remove_Directory
- REM Remove Subdirectory and Files
- RD "%1" /S /Q
- GOTO :EOF
- EndLocal
Add Comment
Please, Sign In to add comment