Advertisement
Guest User

Move/Extract, Convert, Rename

a guest
Dec 11th, 2011
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 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. IF !ERRORLEVEL! NEQ 0 (
  19. ECHO Extraction Error in %%i
  20. ECHO.
  21. ) ELSE (
  22.  
  23. REM Remove Subdirectory and Files
  24.  
  25. RD "%%i" /S /Q
  26. )
  27. ) ELSE (
  28.  
  29. REM If no rars, move video files to the downloads directory
  30.  
  31. FOR %%j IN ( %%i\*.mkv %%i\*.avi) DO (
  32. IF %%j == "" (
  33. ECHO No Valid filetypes to Move
  34. ECHO.
  35. ) ELSE (
  36. MOVE /Y "%%i\%%j" %UserProfile%\Downloads
  37. ECHO.
  38.  
  39. REM Error handling so that unmoved files aren't deleted
  40.  
  41. IF !ERRORLEVEL! NEQ 0 (
  42. ECHO Move %%~xj Error in %%i
  43. ECHO.
  44. ) ELSE (
  45.  
  46. REM Remove Subdirectory and Files
  47.  
  48. RD "%%i" /S /Q
  49. )
  50. )
  51. )
  52. )
  53. )
  54. ) ELSE (
  55. ECHO No Subdirectories With Files to Move or Extract
  56. ECHO.
  57. )
  58.  
  59. REM Convert MKV to MP4 for easier streaming and better device support
  60.  
  61. IF EXIST *.mkv (
  62. FOR %%v IN (*.mkv) DO (
  63.  
  64. REM Timestamp for progress report
  65.  
  66. ECHO Begin converting %%v at !TIME!
  67. ECHO.
  68.  
  69. REM Use FFMpeg to copy audio and video streams into an MP4 container (plus some switches for limited verbosity)
  70.  
  71. "%ProgramFiles(x86)%\ffmpeg\bin\ffmpeg.exe" -loglevel error -v 1 -i "%%v" -vcodec copy -acodec copy "%%~nv.mp4" >NUL
  72. ECHO.
  73.  
  74. REM Error handling so unconverted files are not deleted
  75.  
  76. if !ERRORLEVEL! NEQ 0 (
  77. ECHO Conversion Error on %%v
  78. ECHO.
  79. ) ELSE (
  80.  
  81. REM Second timestamp for progress report
  82.  
  83. ECHO %%~nv.mp4 complete at !time!
  84. ECHO.
  85. DEL "%%v"
  86. )
  87. )
  88. ) ELSE (
  89. ECHO No MKVs to Convert
  90. ECHO.
  91. )
  92.  
  93. REM Check for files named with specific format to rename - e.g. Showname.s01e01.Showtitle.Resolution.Group.mp4
  94.  
  95. IF EXIST *.s*.* (
  96. ECHO Renaming Files
  97. ECHO.
  98. "%ProgramFiles(x86)%\theRenamer\theRenamer" -fetch
  99. ) ELSE (
  100. ECHO Nothing to Rename
  101. ECHO.
  102. )
  103. PAUSE
  104. EndLocal
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement