0

我根据我发现的另一个脚本为自己编写了一个脚本,但我无法弄清楚它为什么不起作用。

它应该如何工作是一旦种子下载完成,它就会运行脚本并获取种子上的标签。为了测试,我正在下载一首带有 Music 标签的歌曲。当它到达 :copyfile 时,它​​不会将它移动到正确的目录中。它没有移动到 F:\Completed Torrents\Music,而是移动到 F:\Completed Torrents。

有人可以指出我错过了什么,因为我已经看过三次了,这让我发疯了。脚本如下。

@echo off
title Liam's torrent-file script
rem 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%

set fromdir=%1
set name=%2
set label=%3
set kind=%4
set filename=%5
set savepartition="F:\Completed Torrents"
set winrar="C:\Program Files (x86)\WinRAR\WinRAR.exe"
set torrentlog="F:\Torrent Scripts\logs\torrentlog.txt"
set handledlog="F:\Torrent Scripts\logs\handled_torrents.txt"
set errorlog="F:\Torrent Scripts\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%=="Movies" goto known
if %label%=="Music" goto known
if %label_prefix%=="TV" goto TV


rem Last resort
rem Double underscores so the folders are easier to spot (listed on top in explorer)
echo Last Resort
set todir=%savepartition%\Unsorted\__%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

:TV
echo **Known Download Type - %label%
set todir=%savepartition%\%label_prefix%\%label_suffix%
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
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

: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

编辑 另外,由于某种原因,在第 39 行没有任何内容打印到日志中。对于那些希望查看带有行号的代码的人:http: //hastebin.com/juqokefoxa.dos

4

2 回答 2

1

给你几点:

1)很可能,您的脚本没有移动文件。首选项/目录有一个选项可以在完成后移动下载。验证这些设置是否没有移动文件。

2) uTorrent 在完成时锁定文件,以便继续播种。要更改此行为,请转到 Preferences / Advanced 并将 bt.read_only_on_complete 设置为 false

3)你仍然会被挫败,因为“当种子完成时运行这个程序”并没有真正做到它所说的。它在下载达到 100% 时运行程序,但 uTorrent 仍在移动文件或播种。在这里查看我的错误报告。

帖子的快速摘要,以防帖子被删除:您必须在“当种子更改状态时运行此程序:”中设置命令,添加 %S 参数并检查 %S == 11

4) 只是我尝试做一些非常相似的事情的一个提示:当您从参数设置变量时,添加一个波浪号(%~1 而不是 %1)。这将去掉引号,让我们稍后更轻松地使用变量构建命令行。

于 2015-03-16T07:03:12.807 回答
0

你说日志没有被写入。试试这个作为测试,看看它是否写入日志。

如果没有,则存在其他一些基本问题。

@echo off
title Liam's torrent-file script
rem 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%

set "fromdir=%~1"
set "name=%~2"
set "label=%~3"
set "kind=%~4"
set "filename=%~5"
set "savepartition=F:\Completed Torrents"
set "winrar=C:\Program Files (x86)\WinRAR\WinRAR.exe"
set "torrentlog=F:\Torrent Scripts\logs\torrentlog.txt"
set "handledlog=F:\Torrent Scripts\logs\handled_torrents.txt"
set "errorlog=F:\Torrent Scripts\logs\ErrorLog.txt"
set "label_prefix="

set "handledlog=%userprofile%\desktop\handled_torrents.txt"

>> "%handledlog%" echo Input: "%fromdir%" "%name%" "%label%" "%kind%" "%filename%"
>> "%handledlog%" echo %date% at %time%: Handling "%label%" torrent "%name%"
于 2014-01-11T01:16:43.750 回答