Guest User

Untitled

a guest
Apr 27th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. @ECHO OFF
  2. CLS
  3. SetLocal EnableDelayedExpansion
  4.  
  5. REM Find TV Show Subdirectories
  6.  
  7. IF EXIST %UserProfile%\Downloads\*hdtv* (
  8. FOR /F "tokens=* delims= " %%i IN ('DIR %UserProfile%\Downloads\*hdtv* /ad/b') DO (
  9.  
  10. REM If there are rar files, unrar them into the downloads directory
  11.  
  12. IF EXIST %%i\*.rar (
  13. "C:\%ProgramFiles%\7-Zip\7z" e "%%i\*.rar" -o%UserProfile%\Downloads
  14. ECHO.
  15.  
  16. REM Error handling so that unextracted files aren't deleted
  17.  
  18. CALL :Delete_on_Success !ERRORLEVEL! Archive Extraction %%i
  19.  
  20. REM If no rars, move video files to the downloads directory
  21.  
  22. ) ELSE (
  23. FOR %%j IN ( %%i\*.mkv %%i\*.avi) DO (
  24. IF %%j == "" (
  25. ECHO No Valid filetypes to Move
  26. ECHO.
  27. ) ELSE (
  28. MOVE /Y "%%i\%%j" %UserProfile%\Downloads
  29. ECHO.
  30.  
  31. REM Error handling so that unmoved files aren't deleted
  32.  
  33. CALL :Delete_on_Success !ERRORLEVEL! %%~xj Move %%i
  34. )
  35. )
  36. )
  37. )
  38. ) ELSE (
  39. ECHO No Subdirectories With Files to Move or Extract
  40. ECHO.
  41. )
  42.  
  43. REM Convert MKV to MP4 for easier streaming and better device support
  44.  
  45. IF EXIST *.mkv (
  46. FOR %%v IN (*.mkv) DO (
  47.  
  48. REM Timestamp for progress report
  49.  
  50. ECHO Begin converting %%v at !TIME!
  51. ECHO.
  52.  
  53. REM Use FFMpeg to copy audio and video streams into an MP4 container (plus some switches for limited verbosity)
  54.  
  55. "%ProgramFiles(x86)%\ffmpeg\bin\ffmpeg.exe" -loglevel error -v 1 -i "%%v" -vcodec copy -acodec copy "%%~nv.mp4" >NUL
  56. ECHO.
  57.  
  58. REM Error handling so unconverted files are not deleted
  59.  
  60. IF !ERRORLEVEL! NEQ 0 (
  61. ECHO Conversion Error on %%v
  62. ECHO.
  63. ) ELSE (
  64.  
  65. REM Second timestamp for progress report
  66.  
  67. ECHO %%~nv.mp4 complete at !time!
  68. ECHO.
  69. DEL "%%v"
  70. )
  71. )
  72. ) ELSE (
  73. ECHO No MKVs to Convert
  74. ECHO.
  75. )
  76.  
  77. REM Check for files named with specific format to rename - e.g. Showname.s01e01.Showtitle.Resolution.Group.mp4
  78.  
  79. IF EXIST *.s*.* (
  80. ECHO Renaming Files
  81. ECHO.
  82. "%ProgramFiles(x86)%\theRenamer\theRenamer" -fetch
  83. ) ELSE (
  84. ECHO Nothing to Rename
  85. ECHO.
  86. )
  87. PAUSE
  88.  
  89. :Delete_on_Success
  90.  
  91. REM Passed Arguments are ERRORLEVEL, filetype, action, directory
  92.  
  93. IF %1 NEQ 0 (
  94. ECHO %2 %3 Error in %4
  95. ECHO.
  96. ) ELSE (
  97. CALL :Remove_Directory %4
  98. )
  99. GOTO :EOF
  100.  
  101. :Remove_Directory
  102.  
  103. REM Remove Subdirectory and Files
  104.  
  105. RD "%1" /S /Q
  106. GOTO :EOF
  107.  
  108. EndLocal
Add Comment
Please, Sign In to add comment