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.
"%arg2"
should be"%arg2%
"