TunB Posted December 22, 2012 Report Share Posted December 22, 2012 I would like to add a warning when using this script, that if you use the network speed tester and have a delete script enabled, it will stop all seeding torrents (therefore their state is 11) and they will be deleted if that's what you have set..I just learned that the hard way haha. Link to comment Share on other sites More sharing options...
mentalwall Posted March 13, 2013 Report Share Posted March 13, 2013 Hi All, I'm new to bash scripts and stuff but am on my quest to a fully automated media centre. I have been trying to implement this script in my set up to remove and delete torrents when completed.For my set up I run filebot when a torrent completes, this extracts and organises my media and uses a "hardlink" so the torrent can remain active but my media be arranged as I would like.Then I have used a variation of Axman's deletescritpt which is below, to remove the data from my torrent folder. @echo offtitle Deleting Torrents Scriptrem Only run if state is finished (11), delete torrent with all filesif %3%=="11" goto continueGOTO:EOF:continue rem Parameter usage: basedir torrent-name state kind [filename]rem corresponds to uTorrents flags: %D %N %S %K %F %Lecho *********************************************echo Run on %date% at %time%set basedir=%1set name=%2set state=%3set kind=%4set filename=%5set label=%6echo Input: %basedir% %name% %state% %kind% %filename% %label%echo %date% at %time%: Handling torrent %name% >> deleted_torrents.txtcall D:\tremove.batrem If label starts with "Shows"if %label%=="TV-Shows" goto deletingif %label%=="Films" goto deletingGOTO:notdeletingGOTO:EOF:deletingecho **Deleting if %kind%=="single" goto deletefile if %kind%=="multi" goto deleteall echo ERROR - Unrecognized kind (%kind%)GOTO:EOF:deletefileecho Deleting file %basedir%\%filename%del %basedir%\%filename%GOTO:EOF:deleteallrem Simply some precautions hereif %basedir%=="D:\_Temp" exitif %basedir%=="D:\TV Shows" exitif %basedir%=="D:\Movies" exitif %basedir%=="D:\Music" exitif %basedir%=="D:\" exitif %basedir%=="C:\" exitecho Deleting directory %basedir% with all subcontentrmdir /S /Q %basedir%GOTO:EOF:notdeletingecho File not a TV Show or FilmGOTO:EOFMy aim was to use the php scritpt found here: http://forum.utorrent.com/viewtopic.php?id=89110 to remove the torrent from utorrent when the ratio is met. As you can see I try to call another script called tremove.bat after the variables are set, which should then run the php script.start C:\webserver\PHP\php.exe -f D:\Scripts\PHPRemove\remove.phpecho removed exitThe php script runs from the CLI if I write php.exe D:\Scripts\PHPRemove\remove.php the script works and also if I make a batch script which contains call php.exe D:\Scripts\PHPRemove\remove.phpIf anyone can see were I may have gone wrong that would be greatly appreciated. I'm pretty new to batch and php and have mainly be learning it to set this up.Thanks Link to comment Share on other sites More sharing options...
burningfire87 Posted November 18, 2013 Report Share Posted November 18, 2013 I have revised the script from Axman84 to include plex updates , Debug Logs, and use Extractnow which detects everything in folder and extracts it Same as Axman84 C:\Users\Admin\Desktop\utorrent.bat "%D" "%N" "%L" "%K" "%F" Run when Torrent Finished@echo offtitle Axmans torrent-file scriptrem Parameter usage: fromdir torrent-name label kind [filename]rem corresponds to uTorrents flags: %D %N %L %K %F echo *********************************************echo Run on %date% at %time%timeout /t 3 /nobreakset fromdir=%1set name=%2set label=%3set kind=%4set filename=%5set savepartition=S:set moviedir=%fromdir%set appsdir=%savepartition%\Extracted\Applicationsset gamesdir=%savepartition%\Extracted\Gamesset tvdir="%savepartition%\Extracted\HD TV"set garytvdir="%savepartition%\Extracted\Gary TV"rem set label_prefix=""echo Input: %fromdir% %name% %label% %kind% %filename%rem Determine length of label stringrem echo.%label%>lenrem for %%a in (len) do set /a len=%%~za -2rem This is to pick up if label begins with "Shows" (ex. "Shows\Boardwalk Empire")rem if %len% geq 7 set label_prefix=%label:~1,5%rem echo label_prefix = %label_prefix%echo %date% at %time%: Torrent %name% with label %label% snagged >> "C:\Users\Admin\Desktop\Utorrent Logs\Grabbed_torrents.txt"rem If label is "Movies"if %label%=="HD Movies" goto HD_Moviesrem If label is "TV"if %label%=="HD TV" goto HDTVrem If label is "Applications"if %label%=="Applications" goto Applicationsrem If label is "PC Games"if %label%=="PC Games" goto Gamesrem If label is "Gary TV"if %label%=="Gary TV" goto Gary_TVrem Last resortrem Double underscores so the folders are easier to spot (listed on top in explorer)rem set todir=%savepartition%\Extracted\__%name%if %kind%=="single" goto failedif %kind%=="multi" goto failedGOTO:EOFrem xcopy switches:rem S Copies directories and subdirectories except empty ones.rem I If destination does not exist and copying more than one file, assumes that destination must be a directory.rem L Displays files that would be copied. FOR DEBUGrem Y Suppresses prompting to confirm you want to overwrite an existing destination file.:HD_Moviesecho **Movieset todir=%moviedir%\%name%echo todir = %todir%rem If there are rar files in the folder, extract them.rem if %kind%=="single" goto copyfilerem if exist %fromdir%\*.mkv goto copymkvsif exist %fromdir%\*.rar goto extractrarecho Guess we didnt find anythingGOTO:EOF:HDTVecho **TVset todir=%tvdir%\%name%if %kind%=="single" goto copyfile if exist %fromdir%\*.rar goto extractrarecho Guess we didnt find anythingGOTO:EOF:Gary_TVecho **Gary_TVset todir=%garytvdir%\%name%if %kind%=="single" goto copyfileif exist %fromdir%\*.rar goto extractrarecho Guess we didnt find anythingGOTO:EOF:Applicationsecho **Applicationsset todir=%appsdir%\%name%rem if %kind%=="single" goto copyfilerem if %kind%=="multi" goto copyallgoto extractrarGOTO:EOF:Gamesecho **Gamesset todir=%gamesdir%\%name%if %kind%=="single" goto copyfilegoto extractrarrGOTO:EOF:copyallecho **Undefinedecho Copy all contents of %fromdir% to %todir%xcopy %fromdir%\*.* %todir% /S /I /YGOTO:EOF:copyfilerem Copies single file from fromdir to todirecho Copy %filename% from %fromdir% to %todir%xcopy %fromdir%\%filename% %todir%\ /S /YGOTO:EOF:copymkvsecho Copy all mkvs from %fromdir% and subdirs to %todir%xcopy %fromdir%\*.mkv %todir% /S /I /YGOTO:EOF:extractrarecho Extracts all rars in %fromdir% to %todir%if not exist %todir% mkdir %todir%if %label%=="HD TV" goto Extract_TVif %label%=="HD Movies" goto Extract_Moviesif %label%=="Gary TV" goto Extract_GaryTVif %label%=="Games" goto Extract_Gamesif %label%=="Applications" goto Extract_Applicationsrem "C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\Gary TV\"rem echo %date% at %time%: Torrent %name% with label %label% to dir %todir% >> "C:\Users\Admin\Desktop\Utorrent Logs\Extracted_torrents.txt"GOTO:EOF:Extract_TV"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\HD TV\{ArchiveFolderName}"GOTO Plex_Update:Extract_Movies"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "{ArchiveFolderName}"GOTO Plex_Update:Extract_GaryTV"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir%" /target "s:\Extracted\Gary TV\{ArchiveFolderName}"GOTO Plex_Update:Extract_Games"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\Games\{ArchiveFolderName}"GOTO:EOF:Extract_Applications"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\Applications\{ArchiveFolderName}"GOTO:EOF:extractrar2echo Extracts all rars in %fromdir% to %todir%. rem Requires WinRar installed to c:\Program filesif not exist %todir% mkdir %todir%"c:\program files\winrar\winrar.exe" x -o+ -ilog %fromdir%\*.rar *.* %todir%echo %date% at %time%: Torrent %name% with label %label% to dir %todir% >> "C:\Users\Admin\Desktop\Utorrent Logs\Extracted_torrents.txt"GOTO Plex_Update:failedecho %date% at %time%: Torrent %name% with label %label% >> "C:\Users\Admin\Desktop\Utorrent Logs\Failed.txt"GOTO:EOF:Plex_Updaterem If the file is media Then update Plex. rem Not used for other file types at this point but it might be expandedrem update the plex section. For more info see http://wiki.plexapp.com/index.php/PlexNine_AdvancedInfo#Terminal_Commandsif %label%=="HD TV" goto Refresh_TVif %label%=="HD Movies" goto Refresh_Moviesif %label%=="Gary TV" goto Refresh_GaryTVGOTO:EOF:Refresh_TV"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --section 1GOTO:EOF:Refresh_Movies"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --section 3GOTO:EOF:Refresh_GaryTV"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --section 4GOTO:EOFIf anyone needs any help customizing I can lend a handCredit for Script goes to Axman84 for the Original Script Link to comment Share on other sites More sharing options...
Dannermax Posted November 23, 2013 Report Share Posted November 23, 2013 Burningfire.. this is awesome!!I was looking for something like this.. But if you could help me customizing it a bit, i would be really, really happy!!My server is running on a debian based linux system, so what are my options?What i need is, that the script copies the downloaded files to a folder, individually for each label, when the download had finished...So for the label "familyguy"the files would be copied to /media/tv/Family Guy/And for the label "movie"the files would be copied to /media/movie/and so on...Nothing needs to be extracted or postprocessed in any way. (or if its not too difficult, then how can extraction be included, but deactivated, to start with? (my mediacenter uses XBMC, and xbmc supports playback of mediafiles inside rar files...)Would this be possible with your script?Looking forward to hear from you..! :-) Link to comment Share on other sites More sharing options...
burningfire87 Posted November 26, 2013 Report Share Posted November 26, 2013 Everything possible Just somethings needed to help with efficient scripting that I need from you1. Where files are downloaded to ? ie. Same folder of different folders2. Do you want the files that are downloaded Moved / Moved then Extracted or Just extracted.3. Type of file formats expected to be encountered? ie.. .rar/.mkv/avi.mp4.zip Depending on those answers I should be able to give you something simple you can edit and build upon.Warning my Linux is rusty but still works last time I checked ....Also if you wanted to you can run Utorrent using Wine to possibly make thing easier for you Link to comment Share on other sites More sharing options...
burningfire87 Posted November 26, 2013 Report Share Posted November 26, 2013 Updated Version Changes: :Cleaned up unused code:Extracted Files will Maintain Directory Structure of where they are downloaded to @echo offtitle Axmans torrent-file scriptrem Parameter usage: fromdir torrent-name label kind [filename]rem corresponds to uTorrents flags: %D %N %L %K %F echo *********************************************echo Run on %date% at %time%timeout /t 3 /nobreakset fromdir=%1set name=%2set label=%3set kind=%4set filename=%5set savepartition=S:set moviedir=%fromdir%set appsdir=%savepartition%\Extracted\Applicationsset gamesdir=%savepartition%\Extracted\Gamesset tvdir="%savepartition%\Extracted\HD TV"set garytvdir="%savepartition%\Extracted\Gary TV"rem set label_prefix=""echo Input: %fromdir% %name% %label% %kind% %filename%rem Determine length of label stringrem echo.%label%>lenrem for %%a in (len) do set /a len=%%~za -2rem This is to pick up if label begins with "Shows" (ex. "Shows\Boardwalk Empire")rem if %len% geq 7 set label_prefix=%label:~1,5%rem echo label_prefix = %label_prefix%echo %date% at %time%: Torrent %name% with label %label% snagged >> "C:\Users\Admin\Desktop\Utorrent Logs\Grabbed_torrents.txt"rem If label is "Movies"if %label%=="HD Movies" goto HD_Moviesrem If label is "TV"if %label%=="HD TV" goto HDTVrem If label is "Applications"if %label%=="Applications" goto Applicationsrem If label is "PC Games"if %label%=="PC Games" goto PC_Gamesrem If label is "Gary TV"if %label%=="Gary TV" goto Gary_TVGOTO:EOFrem xcopy switches:rem S Copies directories and subdirectories except empty ones.rem I If destination does not exist and copying more than one file, assumes that destination must be a directory.rem L Displays files that would be copied. FOR DEBUGrem Y Suppresses prompting to confirm you want to overwrite an existing destination file.:HD_Moviesecho **Movieset todir=%moviedir%\%name%echo todir = %todir%rem If there are rar files in the folder, extract them.rem if %kind%=="single" goto copyfilerem if exist %fromdir%\*.mkv goto copymkvsgoto extractrarecho Guess we didnt find anythingGOTO:EOF:HDTVecho **TVset todir=%tvdir%\%name%if %kind%=="single" goto copyfile goto extractrarecho Guess we didnt find anythingGOTO:EOF:Gary_TVecho **Gary_TVset todir=%garytvdir%\%name%if %kind%=="single" goto copyfilegoto extractrarecho Guess we didnt find anythingGOTO:EOF:Applicationsecho **Applicationsset todir=%appsdir%\%name%rem if %kind%=="single" goto copyfilerem if %kind%=="multi" goto copyallgoto extractrarGOTO:EOF:PC_Gamesecho **Gamesset todir=%gamesdir%\%name%if %kind%=="single" goto copyfilegoto extractrarGOTO:EOF:copyallecho **Undefinedecho Copy all contents of %fromdir% to %todir%xcopy %fromdir%\*.* %todir% /S /I /YGOTO:EOF:copyfilerem Copies single file from fromdir to todirecho Copy %filename% from %fromdir% to %todir%xcopy %fromdir%\%filename% %todir%\ /S /YGOTO:EOF:copymkvsecho Copy all mkvs from %fromdir% and subdirs to %todir%xcopy %fromdir%\*.mkv %todir% /S /I /YGOTO:EOF:extractrarecho Extracts all rars in %fromdir% to %todir%if %label%=="HD TV" goto Extract_TVif %label%=="HD Movies" goto Extract_Moviesif %label%=="Gary TV" goto Extract_GaryTVif %label%=="PC Games" goto Extract_PC_Gamesif %label%=="Applications" goto Extract_ApplicationsGOTO:EOF:Extract_TV"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\{ArchiveFolderStructure}"GOTO Plex_Update:Extract_Movies"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "{ArchiveFolderName}"GOTO Plex_Update:Extract_GaryTV"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir%" /target "s:\Extracted\{ArchiveFolderStructure}"GOTO Plex_Update:Extract_PC_Games"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\{ArchiveFolderStructure}"GOTO:EOF:Extract_Applications"C:\Program Files (x86)\ExtractNow\extractnow.exe" %fromdir% /target "s:\Extracted\{ArchiveFolderStructure}"GOTO:EOF:failedecho %date% at %time%: Torrent %name% with label %label% >> "C:\Users\Admin\Desktop\Utorrent Logs\Failed.txt"GOTO:EOF:Plex_Updaterem If the file is media Then update Plex. rem Not used for other file types at this point but it might be expandedrem update the plex section. For more info see http://wiki.plexapp.com/index.php/PlexNine_AdvancedInfo#Terminal_Commandsif %label%=="HD TV" goto Refresh_TVif %label%=="HD Movies" goto Refresh_Moviesif %label%=="Gary TV" goto Refresh_GaryTVGOTO:EOF:Refresh_TV"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --section 1GOTO:EOF:Refresh_Movies"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --section 3GOTO:EOF:Refresh_GaryTV"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --section 4GOTO:EOF Link to comment Share on other sites More sharing options...
raredown Posted November 26, 2013 Report Share Posted November 26, 2013 I tried this version does not workhttp://s3.nwgat.net/lftp-win/lftp%204.4.10%20win32.7zlftp 4.4.10 win32Error on line 15Please guideI use a seedbox, so I want to start a FTP script that automatically upload a finished torrent back to my home server. I have found an excellent client named "lftp" for this purpose as it allows parallel upload and recursive functionality. Script supports both multi and single file torrents. This script assumes you have a label set, you might have errors without it.Command in µTorrent: C:\Utils\Scripts\ftp.vbs %K "%D" "%N" %L "%F"Script:'save as ftp.vbsDim path,label,cmd,nm,file,tp,host,user,pass,dir,drive,login,lftp,wd, contexthost = "myHostOrIP"user = "myUsername"pass = "myPassword"login = user & ":" & pass & "@" & hostlftp = "C:\Utils\lftp\lftp.exe"wd = "C:\"tp = WScript.Arguments.Item(0) 'single/multidir = WScript.Arguments.Item(1)drive = LCase(Mid(dir, 1, 1))path = "/cygdrive/" & drive & Right(dir,Len(dir)-2)path = Replace(Replace(path,"\","/")," ","\ ")nm = Replace(Replace(WScript.Arguments.Item(2),"\","/")," ","\ ")file = path & "/" & Replace(Replace(WScript.Arguments.Item(4),"\","/")," ","\ ")label = WScript.Arguments.Item(3)If tp = "single" Thencontext = "cd /" & label & "; put " & fileElse'multifilecontext = "mirror -R -v --parallel=3 --depth-first " & path & " /" & label & "/" & nmEnd Ifcmd = "ftp://" & login & " -e " & chr(34) & "set ftp:nop-interval 1; set net:timeout 5; "& context & "; quit" & chr(34)Set objShell = CreateObject("Shell.Application")objShell.ShellExecute lftp, cmd, wd, "runas", 1Set objShell = Nothing Link to comment Share on other sites More sharing options...
Dannermax Posted November 26, 2013 Report Share Posted November 26, 2013 Hey Burningfire. Thanks for the reply.1. At the moment my files are only downloaded to the folder i specify. But if i had a script, i would download them to this temporary folder:/torrent/temp/And then i would like the files to be extracted to either:this folder for tv shows: (each tv show in its own folder - depending on the label i give it)/torrent/tv/family guy/or/torrent/tv/White Collar/And for movies (all movies go in the same folder, but in their own folders:/torrent/movie/2. I would very much like the files to be only extracted. I need to keep a good seed ratio, so i will delete the original files myself, when they are ready for it. 3. Format types, that are expected are rar/mkv/srt/avi/mp4/mpgThat is all i can think of right now. If there is anything else, please let me know. So could i change some of the folder paths, and filenames encountered later on if i would need to?I'm really looking forward to see what you come up with! Once again, thanks so much for your help!!!!By the way...I will remember what you said about Wine..but for now i have Utorrent working pretty good on my Debian setup.. Link to comment Share on other sites More sharing options...
burningfire87 Posted November 27, 2013 Report Share Posted November 27, 2013 Glad to help let me jsut break out my linux book for this part Link to comment Share on other sites More sharing options...
Dannermax Posted January 18, 2014 Report Share Posted January 18, 2014 Any progress yet? Link to comment Share on other sites More sharing options...
Scratch Posted September 30, 2014 Report Share Posted September 30, 2014 Sorry to Necro but I'm trying to figure something out and its not too dissimilar to what the OP is doing. Current Setup:UT2..2.1 on W7(Migrating to 08R2 box)RSS feed for 90% of my contentNot using lables When a torrent finishes I currently run a script which checks if its TV and then calls xcopy to start copying it into \Dropbox\Tv then closes. Its kind of hacked together, but it works perfectly and when I turn on my laptop my "to be watched" stuff instantly starts syncing. Super. What I want to do:Implement a second script to be called after the TV->Dropbox one that cleans up my download directory and sorts content out. Right now I have \Incomplete\ and \Complete\ only, what I'm moving to is \Incomplete\ \Complete\ AND \TV\[show]\, \Movies\ and \Misc\. With infinite seeding. This basically means implementing UT's "Set Download Location..." button into a script so that the files move as per my rules and UT follows them and the seed is continued. Plex and my FTP server will do the rest from there. Anything that doesnt match can be left in \Complete\ and I'll move it manually. In summary, is there any way to call UT and get it to do the move, or can I implement it by copying the files, updating utorrents resume.dat and then deleting the source files? Would this require rebooting UT every time? Thanks,Scratch Link to comment Share on other sites More sharing options...
DreadWingKnight Posted September 30, 2014 Report Share Posted September 30, 2014 UT2..2.1Not supported. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.