본문 바로가기
정보기술/일반

Examples of automatic handling of finished downloads (scripts) - uTorrent

by fermi 2012. 9. 3.

참고: http://forum.utorrent.com/viewtopic.php?pid=678162


C:\Path\TorrentScript.bat > C:\Path\TorrentLog.txt


시나리오: download 완료 -> 자동으로 email을 보내고 -> 파일인지 폴더인지 구분하여 자막파일의 encoding을 utf-8로 변경하고 -> 지정된 위치로 복사 -> 완료 email 발송


requirements:

- sendEmail (command prompt를 이용한 win32 mail) v1.56

http://caspian.dotconf.net/menu/Software/SendEmail/

- iconv Win32 

http://gnuwin32.sourceforge.net/packages/libiconv.htm


.bat 파일 예를 들면:


rem C:\Users\fermi\Desktop\TorrentScript.bat "%D" "%N" "%L" "%K" "%F"


set fromdir=%1

set name=%2

set label=%3

set kind=%4

set filename=%5

set todir=Y:\media\Videos\@Torrent


"C:\Program Files\sendEmail-v156\sendEmail.exe" -f "uTorrent <from_email_address>" -t to_email_address -u "Download Complete" -m %name% -s smtp.gmail.com:587 -xu username -xp password -o tls=yes -o message-charset=utf-8


if %kind%=="single" goto copyfile

if %kind%=="multi" goto subtitles


GOTO:EOF


:copyfile

xcopy %fromdir%\%filename% %todir%\ /S /Y

goto email

GOTO:EOF


:copyall

xcopy %fromdir%\*.* %todir%\%name% /S /I /Y

goto email

GOTO:EOF


:subtitles

D:

cd %fromdir%

dir /S /B %fromdir%\*.smi > subtitles.txt

dir /S /B %fromdir%\*.srt >> subtitles.txt

for /F "delims=" %%i in (subtitles.txt) do move "%%i" "%%i.ansi"

for /F "delims=" %%i in (subtitles.txt) do "c:\Program Files\GnuWin32\bin\iconv.exe" -c -f euc-kr -t utf-8 "%%i.ansi" > "%%i"

del %fromdir%\subtitles.txt

goto copyall

GOTO:EOF


:email

"C:\Program Files\sendEmail-v156\sendEmail.exe" -f "uTorrent <from_email_address>" -t to_email_address -u "Copy Complete" -m %name% -s smtp.gmail.com:587 -xu username -xp password -o tls=yes -o message-charset=utf-8

GOTO:EOF