0

I want to automatically extract torrents downloaded with qBittorrent into the same directory. I have a bat F:\extrator.bat that contains.

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

I call this from qBittorrent on download completion with

"F:\extractor.bat" "%F*.rar" "%F"

The qBittorrent log shows the args passed as arg1 = F:\Torrent\Finished\downloadname*.rar arg2 = F:\Torrent\Finished\downloadname

However Winrar reports an error stating that C:\Windows\System32\"F:\Torrent\Finished\downloadname*.rar" could not be found.

WinRar seems to add C:\Windows\System32\ to the beginning of arg1.

Anyone have any ideas why this is happening?

3
  • Change set arg1=%1 to set "arg1=%~1" and see what happens Aug 28, 2017 at 18:22
  • That now pops up a window that says No Files to extract. My winrar log shows the following. -------- 28/08/2017 20:41:57, Archive F:\Torrent\Finished\The.Housing.Enforcers.S04E07.720p.HDTV.x264-BARGE\the.housing.enforcers.s04e07.720p.hdtv.x264-barge.rar 28/08/2017 20:41:57 No files to extract The files are in the stated location and can be unrared manually with winrar.
    – Finchy70
    Aug 28, 2017 at 19:44
  • Your winrar command line assumes that there is the file/directory The.Housing.Enforcers.S04E07.720p.HDTV.x‌​264-BARGE contained in the archive F:\Torrent\Finished\The.Housing.Enforcers.S04E07.720p.HDTV.x‌​264-BARGE\the.housin‌​g.enforcers.s04e07.7‌​20p.hdtv.x264-barge.‌​rar. Is that so? I guess not. Probably you should omit "%arg2%" completely. Aug 28, 2017 at 20:31

2 Answers 2

1

Got it to work. qBittorrent command was F:\Extractor.bat %F\*.rar %F

extractor.bat placed in root of F

Contains following script:-

timeout /t 10 /nobreak
set "arg1=%~1"
echo "%arg1%"
set "arg2=%2"
shift
shift
"C:\Program Files\WinRAR\WinRAR.exe" x "%arg1%" "%arg2%"

This successfully extracts the archive into the same directory.

1
  • This worked for me, but adapted it to use peazip instead and to extract in the parent folder, like this: timeout /t 10 /nobreak set "arg1=%~1" echo "%arg1%" set "arg2=%2" shift shift "C:\Program Files\PeaZip\peazip.exe" -ext2simple "%arg1%" "%arg2%\..\" Oct 18, 2018 at 22:40
1

Based on previous answers, I distilled and customized the following command:

"C:\Program Files\WinRAR\WinRAR.exe" x -ibck -inul -o+ %F\*.rar %F
  • -ibck will run WinRar in the background
  • -inul will ignore any potential errors that will be thrown. E.g. "No rar file was found"
  • -o+ will override all files that already exists; -o- will skip these.

More info about the command line syntax and switches used by WinRar can be found here:

https://www.winrar-france.fr/winrar_instructions_for_use/source/html/HELPCommandLineSyntax.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .