Last active
August 29, 2015 14:22
-
-
Save b-/4c8461112e1c4db7c1a9 to your computer and use it in GitHub Desktop.
deluge execute script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:addtorrents %torrentid% %torrentname% %torrentpath% | |
::Copies any MP3 files, any M4A files, and any PDF files | |
::::(ONLY copies PDFs if MP3 and/or M4A files are found) | |
::::to the folder D:\autoadd, and adds a line to | |
::::%userprofile%\Music\deluge-script.log with the date/time of script run | |
setlocal | |
set torrentid=%1 | |
set torrentname=%2 | |
set torrentpath=%3 | |
set "log=%userprofile%\Music\deluge-script.log" | |
set autoadd=D:\autoadd | |
@echo on | |
::reset errorlevel | |
set errorlevel= | |
cmd /c exit /b 0 | |
echo Download of %torrentname% Completed at %date% %time%: ^<%torrentpath%\%torrentname%^> ^<%torrentid%^> >> "%log%" | |
pushd %torrentpath%\%torrentname% | |
call:mktmp filestoadd | |
call:findmp3 && call:findpdf | |
call:findm4a && call:findpdf | |
type %filestoadd% | |
for /f "tokens=*" %%a in (%filestoadd%) do (copy /b /d /y "%%a" d:\autoadd) | |
endlocal & del %filestoadd% & exit /b %errorlevel% | |
:findmp3 | |
2>nul 1>> %filestoadd% dir /b /s *.mp3 && exit /b 0 || exit /b 1 | |
:findm4a | |
2>nul 1>> %filestoadd% dir /b /s *.m4a && exit /b 0 || exit /b 1 | |
:findpdf | |
2>nul 1>> %filestoadd% dir /b /s *.pdf && exit /b 0 || exit /b 1 | |
:mktmp (out)tmpfilename | |
setlocal | |
pushd %temp% | |
set tmpfilename=%1 | |
set filename=addtorrents.%tmpfilename%.%random%.tmp | |
type nul>%filename% | |
endlocal & set %tmpfilename%=%temp%\%filename% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment