[WIN] advanced Sample/Subs/etc. directory sorting + unrar

Come up with a useful post-processing script? Share it here!
Post Reply
stormi
Newbie
Newbie
Posts: 1
Joined: June 22nd, 2011, 5:56 pm

[WIN] advanced Sample/Subs/etc. directory sorting + unrar

Post by stormi »

hi everyone,

i am new to sabnzbd and i have to say its great ..love it :D

i read this topic about sample/subs directory sorting for movie scene releases, but it was too insufficient for me and it printed unattractive error messages to the logfile. so i made my own script. unfortunately i didnt know much about dos batch progamming so i had to google a lot.

so lets say there is one single nzb to a movie scene release including par2, nfo, sfv, sample, proof file/s & packed (rar) movie, subs and ac3-addon files or at least some of those ...and you want to store it like you see it in this filetree ->

Image

so the movie should be extracted to the main dir but subtitles and/or ac3-addon files should NOT be extracted ..just moved to a subfolder like sample and/or proof files.

thats a problem to sabnzbd if its all in one nzb file (job) because it does extract every rar file in the directory.

here you can use this post process script. make a new category in sabnzbd and set it to "+Repair" option because the script will unrar the movie file/s.


in this screenshots you see the logs/info for the script in sabnzbd->

1:
Image
2:
Image
3:
Image


script description:
---------- description: - checks for nfo file
------------------------ - creates sample, subs, proof and/or ac3 subfolders
------------------------ - moves files and/or RARs to its subfolders
------------------------ - extracts movie file/s to the main dir
------------------------ - deletes rar files and other stuff in main dir
------------------------ - get a nice report and status line at the end
script usage:
- usage: - CHANGE "G:" TO YOUR HD-LETTER WHERE SABNZBD-DOWNLOAD-FOLDER IS LOCATED!
---------
--------- - ADJUST THE WinRAR-INSTALL-PATH "%programfiles%\WinRAR"
--------- - FOR 64bit WIN VISTA/7 YOU CAN USE "%ProgramFiles(x86)%"
---------
--------- - SAVE CHANGES! xD
---------
--------- - GO TO SABNZBD CONFIG, MAKE A NEW CATEGORY, CHOOSE "+REPAIR"!!!,
--------- - CHOOSE mrlss-SUD-v1b9.bat FROM SCRIPT FOLDER AND SAVE,
--------- - USE THE NEW CATEGORY WHEN ADDING NZBS FROM MOVIE RELEASES. HF!
script code: "mrlss-SUD-v1b9.bat"

Code: Select all

@ECHO OFF

REM ----------- mrlss-SUD-v1b9.bat
REM ----------- movie release sorter - Sort/Unrar/Delete - version 1 build 9
REM ----------- sabnzbd - post-processing-script (windows)
REM
REM ----------- description: - checks for nfo file
REM ------------------------ - creates sample, subs, proof and/or ac3 subfolders
REM ------------------------ - moves files and/or RARs to its subfolders
REM ------------------------ - extracts movie file/s to the main dir
REM ------------------------ - deletes rar files and other stuff in main dir
REM ------------------------ - get a nice report and status line at the end
REM
REM -- usage: - CHANGE "G:" TO YOUR HD-LETTER WHERE SABNZBD-DOWNLOAD-FOLDER IS LOCATED!
REM ---------
REM --------- - ADJUST THE WinRAR-INSTALL-PATH "%programfiles%\WinRAR"
REM --------- - FOR 64bit WIN VISTA/7 YOU CAN USE "%ProgramFiles(x86)%"
REM ---------
REM --------- - SAVE CHANGES! xD
REM ---------
REM --------- - GO TO SABNZBD CONFIG, MAKE A NEW CATEGORY, CHOOSE "+REPAIR"!!!,
REM --------- - CHOOSE mrlss-SUD-v1b9.bat FROM SCRIPT FOLDER AND SAVE,
REM --------- - USE THE NEW CATEGORY WHEN ADDING NZBS FROM MOVIE RELEASES. HF!
REM
REM ----------------- info: - use this script at your own risk (errors might occur)!
REM ----------------------- - checkout sabnzbd forums and help to improve if u like! ;)

SetLocal EnableDelayedExpansion

:MAIN

REM ------------------------- adjust letter to your hard-drive here!!!

G:
cd %1

REM variables for report at the end
set nfovar=0
set samplevar=0
set proofvar=0
set subsvar=0
set ac3var=0
set status=%7
REM variables to delete old format rars later on
FOR /L %%t IN (0,1,9) DO (
	set num=%%t
	if exist "*.rar" set rar=rar
	if exist "*.r0!num!" set rar=r0x
)
FOR /L %%t IN (10,1,99) DO (
	set num=%%t
	if exist "*.r!num!" set rar=rxx
)

REM checking for/printing jobname, nfo, sample, proof, subs and ac3addon
REM if available creating subfolders and moving files
REM subs and ac3addon files wont be extracted this way
:RLS
echo.
echo Release....: %3

:NFO
echo.
if exist *.nfo echo NFO........: Yes & set nfovar=1 & goto SAMPLE
echo NFO........: No

:SAMPLE
echo.
if exist *sample*.* echo Sample.....: Yes & goto sam1
echo Sample.....: No
goto PROOF
:sam1
set samplevar=1
mkdir Sample >NUL 2>&1
move *sample*.* Sample >NUL 2>&1
:PROOF
if exist *proof*.* echo Proof......: Yes & goto proof1
echo Proof......: No
goto SUBS
:proof1
set proofvar=1
mkdir Proof >NUL 2>&1
move *proof*.* Proof >NUL 2>&1
:SUBS
if exist *subs*.* echo Subs.......: Yes & goto subs1
echo Subs.......: No
goto AC3
:subs1
set subsvar=1
mkdir Subs >NUL 2>&1
move *subs*.* Subs >NUL 2>&1
:AC3
if exist *ac3*.* echo AC3-Addon..: Yes & goto ac31
echo AC3-Addon..: No
goto RARFINDER
:ac31
set ac3var=1
mkdir AC3 >NUL 2>&1
move *ac3*.* AC3 >NUL 2>&1

:RARFINDER
REM checks for rars in main dir for extraction
if exist "*.rar" goto WINRARXP
goto TRASH1

:WINRARXP
REM ---------------------adjust the path to your winrar installation path here!!!

set path="%programfiles%\WinRAR";%path%
set directory=%1
set location=%1

:RARTYPE
REM big jump to another extraction procedure if rars are named/parted the normal way
if exist "*.part1.rar" goto EXTR2
if exist "*.part01.rar" goto EXTR2
if exist "*.part001.rar" goto EXTR2


:EXTR1
REM calling extraction procedure for old format rars r00 etc
pushd %directory%
for /F %%i in ('dir /b *.rar') do call :DOEX1 "%%i"
popd

:TRASH1
REM deletes old format rars and other files in main dir as listed
FOR /L %%t IN (0,1,9) DO (
	set num=%%t
	if exist "*.r0!num!" del "*.r0!num!"
)
FOR /L %%t IN (10,1,99) DO (
	set num=%%t
	if exist "*.r!num!" del "*.r!num!"
)
if exist "*.rar" del "*.rar" 2>nul
if exist "*.sfv" del "*.sfv" 2>NUL
if exist "*.nzb" del "*.nzb" 2>NUL
if exist "*.par2" del "*.par2" 2>NUL
if exist "*.url" del "*.url" 2>NUL
if exist "*.txt" del "*.txt" 2>NUL
if exist "*.1" del "*.1" 2>NUL
if exist "*(1)" del "*(1)" 2>NUL

:REPORT1
REM checks sabnzbd post process status 0 means ok
if %status% EQU 0 goto NFOT1
echo Post-Process-Error -SR-
goto eof

:NFOT1
REM cumulates the number of subfolders which were created and prints out the last line of report
echo.
set /a Summe=%samplevar%+%proofvar%+%subsvar%+%ac3var%
if %nfovar% EQU 0 echo Script-Status: OK --- ( - MOVIE - ) - ( -- %Summe% -- Subfolder/s ) - ( - MiSSiNG NFO - )
if %nfovar% EQU 1 echo Script-Status: OK --- ( - MOVIE - ) - ( -- %Summe% -- Subfolder/s ) - ( + NFO + )

goto eof

:DOEX1
echo.
echo.
echo %time% Extracting archive %1...
echo.
unrar.exe e %1 %location%
echo.
echo.
echo %time% Extraction complete.
echo.
echo.
if %status% EQU 0 echo Post-Process-Status: OK -E1-
if not %status% EQU 0 echo Post-Process-Error -E1-
goto eof


:EXTR2
REM extraction procedure for rars named/parted the normal way ..the rest is the same as written before!
pushd %directory%
for /F %%i in ('dir /b *.part1.rar;*.part01.rar;*.part001.rar') do call :DOEX2 "%%i"
popd

:TRASH2
FOR /L %%t IN (0,1,9) DO (
	set num=%%t
	if exist "*.r0!num!" del "*.r0!num!"
)
FOR /L %%t IN (10,1,99) DO (
	set num=%%t
	if exist "*.r!num!" del "*.r!num!"
)
if exist "*.rar" del "*.rar" 2>nul
if exist "*.sfv" del "*.sfv" 2>NUL
if exist "*.nzb" del "*.nzb" 2>NUL
if exist "*.par2" del "*.par2" 2>NUL
if exist "*.url" del "*.url" 2>NUL
if exist "*.txt" del "*.txt" 2>NUL
if exist "*.1" del "*.1" 2>NUL
if exist "*(1)" del "*(1)" 2>NUL

:REPORT2
if %status% EQU 0 goto NFOT2
echo Post-Process-Error -SR-
goto eof

:NFOT2
echo.
set /a Summe=%samplevar%+%proofvar%+%subsvar%+%ac3var%
if %nfovar% EQU 0 echo Script-Status: OK --- ( - MOVIE - ) - ( -- %Summe% -- Subfolder/s ) - ( - MiSSiNG NFO - )
if %nfovar% EQU 1 echo Script-Status: OK --- ( - MOVIE - ) - ( -- %Summe% -- Subfolder/s ) - ( + NFO + )

goto eof

:DOEX2
echo.
echo.
echo %time% Extracting archive %1...
echo.
unrar.exe e %1 %location%
echo.
echo.
echo %time% Extraction complete.
echo.
echo.
if %status% EQU 0 echo Post-Process-Status: OK -E2-
if not %status% EQU 0 echo Post-Process-Error -E2-

:eof
ENDLOCAL
view this code in color @ pastebin -> http://pastebin.com/3QBWSsbL


you can test the script by downloading very small test files from alt.binaries.test ->

usenet-header: movie.test.release.2011.XviD-testgrp
usenet-header: movie.test.release.PART.2.2011.XviD-testgrp
usenet-header: movie.test.release.PART.3.2011.XviD-testgrp

...each test download is packed different and has a different amount of movie files (cds)!


the script works ..but please report errors and let me know what you think of this ..took me some time ;)

greets
stormi


edit1: - screenshots changed
Last edited by stormi on June 26th, 2011, 8:54 am, edited 1 time in total.
User avatar
OfficerDoofy
Newbie
Newbie
Posts: 9
Joined: January 18th, 2011, 5:26 am

Re: [WIN] advanced Sample/Subs/etc. directory sorting + unra

Post by OfficerDoofy »

Thanks for great script! Can anyone tell me how to disable unraring release cuz i need it in original archives? Thanks in advance!
Post Reply