Auto extract .rar files from qbittorrent with WinRAR command line CLI

1

After a torrent download on qbittorrent completes, I am executing an external program via the options menu:

Tools -> Options -> Downloads --> Run external program on torrent completion

"C:\Program Files\WinRAR\AutoUnRAR.bat" "%F\*.rar" "E:\Downloads\"

In the file I have created named AutoUnRAR.bat lies the code:

@ECHO off
timeout /t 10 /nobreak
set arg1=%1
set arg2=%2
shift
shift
START "" "C:\Program Files\WinRAR\WinRAR.exe" x "%arg1%" "%arg2"

A timeout is required, because when I was calling this directly from qbittorrent with the execution:

 "C:\Program Files\WinRAR\WinRAR.exe" x "%F\*.rar" "E:\Downloads\"   

the file is labeled as still being in use (the WinRAR command -dh doesn't work), and WinRAR gives the error "The process cannot access the file because it is being used by another process."

Once the download has finished, and the 10 second countdown ends, WinRAR gives the error

fileDIRECTORY\file.rar: No files to extract

Upon inspection of the folder, the files are indeed there and can be manually extracted, it is for some reason not extracting the .rar file. In this case there happens to be many parts, .r00 .r01 ... and a file with just .rar. I am only targeting the .rar file but WinRAR has no problem when you extract any of the parts singly.

Drew Sanislo

Posted 2016-04-05T02:29:34.303

Reputation: 13

"%arg2" should be "%arg2%" – DavidPostill – 2016-04-05T08:45:07.157

No problem. I've added a proper answer, which you can accept.

– DavidPostill – 2016-04-05T20:34:12.297

Answers

0

WinRAR gives the error "fileDIRECTORY\file.rar: No files to extract"

START "" "C:\Program Files\WinRAR\WinRAR.exe" x "%arg1%" "%arg2"

There is an error in the above command, "%arg2" should be "%arg2% (missing %).

So the command should be:

START "" "C:\Program Files\WinRAR\WinRAR.exe" x "%arg1%" "%arg2%"

DavidPostill

Posted 2016-04-05T02:29:34.303

Reputation: 118 938

0

You don't need to use a .bat for the timeout. You can use this in the Run external program... field of qBittorent.

cmd /c timeout /t 15 & "C:\Program Files\WinRAR\UnRAR.exe" x "%F\*.rar" "%F"

Note: If you need to test a command for this, you can try it in the "run" box on windows.

Note2: You could probably use WinRAR.exe still. UnRAR just keeps everything in the background.

Deathnutz

Posted 2016-04-05T02:29:34.303

Reputation: 1