Angus_Black_1962

qBit Race Script

May 31st, 2023
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.47 KB | Software | 0 0
  1. @echo off
  2. rem qBittorrent command line: C:\Torrents\Download\Move_RACE.bat "%N" "%L" "%F" "%C"
  3. set MedFol=%~dp0
  4. set Log=%MedFol%Move_RACE_Log.txt
  5.  
  6. rem Get yesterday's date to rename files.
  7. for /f %%a in ('cscript //nologo %MedFol%yd.vbs') do set yd=%%a
  8. set yr=%yd:~0,4%
  9. set mn=%yd:~4,2%
  10. set dy=%yd:~6,2%
  11. set yesterday=%yr%.%mn%.%dy%
  12.  
  13. REM *** Change year at the first of each racing season. ***
  14. set year=2023
  15. set season=Season %year%
  16. REM name (Torrent Name) is used to find the NASCAR Series.
  17. set name=%1
  18. REM category, NASCAR, AMA, TV Show, Movie
  19. set category=%2
  20. set contentpath=%3
  21. set filecount=%4
  22. set rootpath=%5
  23. set savepartition=O:\Media\Video\Racing
  24.  
  25. rem If category is NASCAR
  26. if %category%==NASCAR goto NASCAR
  27. rem If category is AMA
  28. if %category%==AMA goto AMA
  29. goto NR
  30.  
  31. :NASCAR
  32. echo ********************************************* >> %Log%
  33. echo Torrent Name: %name% >> %Log%
  34. echo **%category% >> %Log%
  35. echo Start: %date% at %time% >> %Log%
  36. REM Check to see which NASCAR Series the race is.
  37. if not x%name:Cup=%==x%name% goto CS
  38. if not x%name:Truck=%==x%name% goto TS
  39. if not x%name:Xfinity=%==x%name% goto XS
  40. if not x%name:ARCA=%==x%name% goto AR
  41.  
  42. :CS
  43. set sername=NASCAR.Cup.Series
  44. set series=NASCAR Cup Series\%season%
  45. 'if not %filecount%=="1" goto copyall
  46. goto copyone
  47.  
  48. :TS
  49. set sername=NASCAR.Truck.Series
  50. set series=NASCAR Truck Series\%season%
  51. 'if not %filecount%=="1" goto copyall
  52. goto copyone
  53.  
  54. :XS
  55. set sername=NASCAR.Xfinity.Series
  56. set series=NASCAR Xfinity Series\%season%
  57. if not %filecount%=="1" goto copyall
  58. goto copyone
  59.  
  60. :AR
  61. set sername=NASCAR.ARCA.Series
  62. set series=
  63. NASCAR ARCA Series\%season%
  64. 'if not %filecount%=="1" goto copyall
  65. goto copyone
  66.  
  67. :AMA
  68. echo ********************************************* >> %Log%
  69. echo Torrent Name: %name% >> %Log%
  70. echo **%category% >> %Log%
  71. echo Start: %date% at %time% >> %Log%
  72. set sername=AMA.Supercross
  73. set series=AMA Supercross\%season%
  74. 'if not %filecount%=="1" goto copyall
  75. goto copyone
  76.  
  77. :copyone
  78. rem Copies one MKV file from contentpath to todir appending yesterday's date to the beginning of the file name.
  79. set todir="%savepartition%\%series%\"
  80. rem Remove quotes from original todir
  81. set todir=%todir:"=%
  82. echo Copy one file >> %Log%
  83. echo Copy From: %contentpath% >> %Log%
  84. echo Copy To: %todir% >> %Log%
  85.  
  86. REM *** Start Copy ***
  87.   echo copy "%contentpath%" "%todir%%sername%.%yesterday%.%name%" >> %Log%
  88.   copy "%contentpath%" "%todir%%sername%.%yesterday%.%name%" >> %Log%
  89. REM *** End Copy ***
  90. goto errchk
  91.  
  92. :copyall
  93. rem Copies all "race" MKV files from contentpath to todir appending yesterday's date to the beginning of the file name.
  94. set todir="%savepartition%\%series%\"
  95. rem Remove quotes from original todir
  96. set todir=%todir:"=%
  97. echo Copy multi files >> %Log%
  98. echo Copy From: %contentpath% >> %Log%
  99. echo Copy To: %todir% >> %Log%
  100.  
  101. REM *** Start Copy ***
  102. pushd %contentpath%
  103.   setlocal
  104.   setlocal enabledelayedexpansion
  105.   for %%a in (*race*.mkv) do (
  106.       echo copy "%%a" "%todir%%category%.%yesterday%.%%a" >> %Log%
  107.       copy "%%a" "%todir%%sername%.%yesterday%.%%a" >> %Log%
  108.   )
  109.   endlocal
  110. popd
  111. REM *** End Copy ***
  112. goto errchk
  113.  
  114. :errchk
  115. if errorlevel 4 goto errors
  116. if errorlevel 0 goto noerrors
  117.  
  118. :errors
  119. echo Copy FAILED Error: %errorlevel% >> %Log%
  120. echo Insufficient memory to copy files or >> %Log%
  121. echo invalid drive or command-line syntax. >> %Log%
  122. goto EOF
  123.  
  124. :noerrors
  125. echo Copy complete >> %Log%
  126. goto EOF
  127.  
  128. :EOF
  129. echo Finish: %date% at %time% >> %Log%
  130.  
  131. :NR
  132. end
Add Comment
Please, Sign In to add comment