Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rem uTorrent Automatic Download Handler
- rem Author Lynkz83
- rem Inspiration: Axman84 Thread: http://forum.utorrent.com/viewtopic.php?id=110024
- rem Setup this batch file passes the following variables from uTorrent to CMD Prompt:
- rem "%D" "%N" "%L" "%K" "%F"
- rem In order to use, create new folder C:\uScripts\ and place this file in to it.
- rem Open uTorrent and and browse to the created folder and type
- rem "C:\uScripts\uTorrent ADH.bat" "%D" "%N" "%L" "%K" "%F" >> C:\uScripts\Logs\torrentlog.txt
- echo Run on %date% at %time%
- Title uTorrent Automatic Download Handler
- set fromdir=%1
- set name=%2
- set label=%3
- set kind=%4
- set filename=%5
- set savepartition=G:\Media
- set winrar="c:\program files\winrar\winrar.exe"
- set torrentlog=C:\uScripts\Logs\torrentlog.txt
- set handledlog=C:\uScripts\Logs\handled_torrents.txt
- set errorlog=C:\uScripts\Logs\ErrorLog.txt
- set label_prefix=""
- echo Input: %fromdir% %name% %label% %kind% %filename%
- rem Check if the label has a sub label by searching for \
- if x%label:\=%==x%label% goto skipsublabel
- rem Has a sub label so split into prefix and suffix so we can process properly later
- echo sub label
- for /f "tokens=1,2 delims=\ " %%a in ("%label%") do set label_prefix=%%a&set label_suffix=%%b
- rem add the removed quote mark
- set label_prefix=%label_prefix%"
- set label_suffix="%label_suffix%
- echo.prefix : %label_prefix%
- echo.suffix : %label_suffix%
- goto:startprocess
- :skipsublabel
- echo Skipped Sub Label
- goto:startprocess
- :startprocess
- echo %date% at %time%: Handling %label% torrent %name% >> %handledlog%
- rem Process the label
- if %label_prefix%=="Movies" goto known
- if %label_prefix%=="TV" goto known
- if %label_prefix%=="Games" goto known
- if %label_prefix%=="Music" goto known
- if %label_prefix%=="Animation" goto known
- if %label_prefix%=="Applications" goto known
- if %label%=="Books" goto known
- if %label%=="OpenTracker" goto known
- rem Last Resort
- rem This field is for anything that doesnt match the above labels processing
- echo Last Resort
- set todir=%savepartition%\%label%\__%name%
- if %kind%=="single" goto copyfile
- if %kind%=="multi" goto copyall
- GOTO:EOF
- :known
- echo **Known Download Type - %label%
- set todir=%savepartition%\%label%\%name%
- echo todir = %todir%
- GOTO:process
- :process
- rem If there are rar files in the folder, extract them.
- rem If there are mkvs, copy them. Check for rars first in case there is a sample.mkv, then we want the rars
- if %kind%=="single" goto copyfile
- if exist %fromdir%\*.rar goto extractrar
- if exist %fromdir%\*.mkv goto copymkvs
- if %kind%=="multi" goto copyall
- if exist %fromdir%\cd1\*.rar goto :unpack_CD1_rar
- echo Guess we didnt find anything
- GOTO:EOF
- :copyall
- echo **Type unidentified so copying all
- echo Copy all contents of %fromdir% to %todir%
- xcopy %fromdir%\*.* %todir% /S /I /Y
- GOTO:EOF
- :copyfile
- rem Copies single file from fromdir to todir
- echo Single file so just copying
- echo Copy %filename% from %fromdir% to %todir%
- xcopy %fromdir%\%filename% %todir%\ /S /Y
- GOTO:EOF
- :copymkvs
- echo Copy all mkvs from %fromdir% and subdirs to %todir%
- xcopy %fromdir%\*.mkv %todir% /S /I /Y
- GOTO:EOF
- :unpack_CD1_rar
- IF EXIST %fromdir%\subs xcopy %fromdir%\subs %todir% /S /I /Y
- IF EXIST %fromdir%\subtitles xcopy %fromdir%\subtitles %todir% /S /I /Y
- call %winrar% x %fromdir%\CD1\*.rar *.* %todir% -IBCK -ilog"%todir%\RarErrors.log"
- goto :unpack_cD2_rar
- :unpack_CD2_rar
- IF EXIST %fromdir%\subs xcopy %fromdir%\subs %todir% /S /I /Y
- IF EXIST %fromdir%\subtitles xcopy %fromdir%\subtitles %todir% /S /I /Y
- call %winrar% x %fromdir%\CD2\*.rar *.* %todir% -IBCK -ilog"%todir%\RarErrors.log"
- goto :EOF
- :extractrar
- echo Extracts all rars in %fromdir% to %todir%.
- rem Requires WinRar installed to c:\Program files
- if not exist %todir% mkdir %todir%
- IF EXIST %fromdir%\subs xcopy %fromdir%\subs %todir% /S /I /Y
- IF EXIST %fromdir%\subtitles xcopy %fromdir%\subtitles %todir% /S /I /Y
- call %winrar% x %fromdir%\*.rar *.* %todir% -IBCK -ilog"%todir%\RarErrors.log"
- IF EXIST %fromdir%\*.nfo xcopy %fromdir%\*.nfo %todir% /S /I /Y
- GOTO:EOF
- :eof
- echo processing complete
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement