Jump to content

Automation: Script that unrars downloads on UNC shares


bkvamme

Recommended Posts

Posted

Hello!

I found a script over at the 7-Zip SourceForge discussion board (http://sourceforge.net/projects/sevenzip/forums/forum/45797/topic/4659614)) that unzip/unrars downloads automaticly.

I took that script and enhanced it to make it work with network (UNC/Samba) shares, and I added an option to only run if the torrent downloaded matches a certain label.

Lots of credit to ikxcsshcm7 over at the SF discussion board!

Requirements:

7-Zip

Windows

Here is the script in question:

I recommend copying from pastebin to avoid any formatting errors.

http://pastebin.com/Wj8yuy7G

:: BEGIN TORRENT_DONE.BAT 
::
:: In uTorrent 'Run Program'
:: enter data like:
:: C:\SCRIPTS\TORRENT_DONE.BAT "%D" "%N" "%L"
::
:: INCLUDE QUOTE MARKS
::
:: Script was written by ikxcsshcm7 at SourceForge
::
::@ECHO OFF
SET PATH=C:\PROGRAM FILES\7-ZIP;%PATH%
SET JOBDIR=%~1
SET JOBNAME=%~2
PUSHD "%JOBDIR%"
:: If you aren't using network shares,
:: comment out the "pushd %jobdir%" line
:: and comment in the line below.
:: CD/D "%JOBDIR"
>JOB_"%JOBNAME%".LOG ECHO.%JOBNAME%
>>JOB_"%JOBNAME%".LOG ECHO.
IF "%3" NEQ "RSS" GOTO DONE
:: If you want to restrict the extraction process
:: change "RSS" to the label you are using.
:: You can also use this to skip specific labels
:: by changing NEQ to EQU.
IF EXIST *.RAR GOTO UNPACK_RAR
IF EXIST CD1\*.RAR GOTO UNPACK_CD1_RAR
IF EXIST *.R01 GOTO UNPACK_R01
IF EXIST *.R00 GOTO UNPACK_R00
IF EXIST *.00 GOTO UNPACK_00
IF EXIST *.ZIP GOTO UNPACK_ZIP
IF EXIST *.7z GOTO UNPACK_7z
GOTO :NO_UNPACK

:UNPACK_RAR
7Z x -y *.RAR >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_CD1_RAR
7Z x -y CD1\*.RAR >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_CD2_RAR
7Z x -y CD2\*.RAR >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_R01
7Z x -y *.R01 >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_R00
7Z x -y *.R00 >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_00
7Z x -y *.00 >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_ZIP
7Z x -y *.ZIP >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:UNPACK_RAR
7Z x -y *.7z >>JOB_"%JOBNAME%".LOG
IF NOT ERRORLEVEL == 0 REN JOB_"%JOBNAME%".LOG ERROR_"%JOBNAME%".LOG
GOTO DONE

:NO_UNPACK
>>JOB_"%JOBNAME%".LOG
ECHO.NO FILES FOUND TO UNPACK >>JOB_"%JOBNAME%".LOG
DIR/B

:DONE
POPD
:: If you are not on a network share, you can comment out "popd" aswell.
::
:: END TORRENT_DONE.BAT

I have only tested the script on .rar files, but it should work on all other compress files. Let me know if it doesn't.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...