[REQ] unRAR Script With KNOWN Password.

Come up with a useful post-processing script? Share it here!
Post Reply
videojaq
Newbie
Newbie
Posts: 8
Joined: September 29th, 2008, 1:47 am

[REQ] unRAR Script With KNOWN Password.

Post by videojaq »

Here's the log from a discussion I had in IRC:
23:23 : anyone know if a post-processing script could be made to unrar archives with a known password?
23:29 : to my knowledge one hasn't been made. if you made one, you'd have to know ahead of time what the password was, and edit the script to have the password. that seems like a lot of work.
23:30 : wouldn't it just be easier to unrar it yourself and enter the password then?
23:32 : not particularly
23:32 : I'm part of a videography discussion group on usenet, and recently some of the members are getting paranoid about their stuff being 'public'
23:32 : in both cases you're going to have to have manual interaction with the files.
23:33 : so we've devised a set password for all of our passwords
23:33 : oh, unless multiple posts are going to have the same password.
23:33 : yes, all the posts will have the same password.
23:33 : until the time where the password will change (maybe once a quarter or something)
23:33 : if you've got that, it should be pretty simple to make a script that does that.
23:34 : any pointers of where to start? I'm a videographer/editor, not a programmer :)
23:34 : hang on
23:34 : ok, thanks
23:37 : basically you'd just need a script that runs unrar e -pyourpassword $1*.rar
23:37 : i think.
23:38 : someone on our post-processing forum should be able to provide you with a windows/linux script that you'd be able to use.
23:38 : http://forums.sabnzbd.org/http://forums ... .php?f=9.0
23:41 : thanks for the help inpheaux -> I'll make a quick post on the boards
23:42 : justaquestion>>be sure to explain in general why you need it (the pre-determined password) so people don't respond like i initially did of "why would you need this?"
23:42 : I'll just copy paste this log :)
23:43 : hah, that works.
23:43 : note: i am probably totally off the mark with that suggested script. unrar takes really weird arguments, and i'm not really sure if that's how to get the right .rar.
23:44 : however, i DO know that what you're asking should be doable.
23:45 : great, thanks.
Other Information:
I'm running SABnzbd on Mac OSX Tiger, and I have another group member who uses SABnzbd on windows -> so if the script worked for both platforms, that would be great!  ;D

I'm not sure if any of you could just write the script, but if you can't -> could you please point me in all the right directions to writing one for myself?
-> as you see in the log above, I'm a videographer/editor, not a programmer  :P


Thanks for your time, and your attention to this matter.
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: [REQ] unRAR Script With KNOWN Password.

Post by switch »

Giving it just the path won't be enough. Should probably run with 'e' instead of 'x' and run it on one (of the possibly many) .rar files in the folder ($1)
videojaq
Newbie
Newbie
Posts: 8
Joined: September 29th, 2008, 1:47 am

Re: [REQ] unRAR Script With KNOWN Password.

Post by videojaq »

I had WAY too many problems trying to get this script to work on my mac, so I dug up my PC to give it a try -> and this is what I get:

Code: Select all

*filename*.log

    
C:\Program Files\SABnzbd>"C:\Program Files\WinRAR\UnRAR.exe" x -idp -o- -p- -p*mypass* $1 $1 

UNRAR 3.71 freeware      Copyright (c) 1993-2007 Alexander Roshal

Cannot open $1.rar
The system cannot find the file specified.
No files to extract
Errors on my mac included everything from files not existing, to permissions problems, to unrar problems. I tried absolutely everything.  :-\
-> but that doesn't matter, since I've decided to hook up my old PC as 'slave' to my network, grabbing all the discussion items I want -> and then it's easily accessibly to me on my mac over my gigabit network.
dwoods99
Newbie
Newbie
Posts: 1
Joined: October 2nd, 2008, 12:40 am

Re: [REQ] unRAR Script With KNOWN Password.

Post by dwoods99 »

Try this code... it works for me from Windows Explorer as right-click option
but with some modifications since my path is hard-coded.
You will need to set the password below and optional DESTination path since
it is passed in from SAB as 1st parameter and will override script setting.

Code: Select all

@ECHO OFF

:: Parameters expected
:: $1 = The final directory of the job (full path)
:: $2 = The name of the NZB file
:: $3 = Clean version of the job name (no path info and ".nzb" removed)
::
:: It is expected that UnRAR.exe are in Windows PATH
::

Echo Params: (%*)

SET PASS=password
SET DEST=R:\Unpacked\

::
:: No user changes below here
::
IF []==[%2] GOTO CONT
IF x""==x%2 GOTO CONT

SET DEST=%~1
SHIFT

:CONT
IF x==x%DEST% SET DEST=

SET FNAME=%~1
SET FULL=%~dp1%
SET NAME=%~f1%

:: check if destination folder exists, if file name passed in exists, if file name is not a folder
IF DEFINED %DEST% (
   IF NOT EXIST %DEST%\nul GOTO ASKIP
)
IF NOT EXIST %FNAME%  GOTO BSKIP
IF EXIST %FNAME%\nul  GOTO BSKIP

IF x"%~x1%"==x".rar" GOTO PROC

SET RAR=%~n1%.part*1.rar

:: Get first RAR file and UnRAR it to destination
FOR /F %%I in ('DIR /B /OD- "%RAR%"') do SET NAME=%FULL%%%I
GOTO PROC

:PROC
@Echo Processing ...
:: - for debugging only -
Echo DEST  (%DEST%)
Echo FNAME (%FNAME%)
Echo FULL  (%FULL%)
Echo NAME  (%NAME%)

@echo C:\Bin\UnRAR x -o- -p%PASS% %NAME% %DEST%
call C:\Bin\UnRAR x -o- -p%PASS% %NAME% %DEST%
SET err=!errorlevel!
IF errorlevel 0 ( GOTO END
) ELSE ( GOTO ERR )

:: no more processing


:ASKIP
Echo Directory %DEST% does not already exist!
Echo Skipping...
GOTO ERR

:BSKIP
Echo File %FNAME% does not exist!
Echo Skipping...
GOTO ERR

:ERR
@echo
:: sndrec32 /embedding /play /close c:\bin\gunshot.wav
echo Error Level Code: %err%
pause
Exit /b %err%

:END 
@Echo 
Echo ...Done Processing
:: sndrec32 /embedding /play /close c:\bin\clap.wav
Exit 0
You can only run one at a time since no queuing is done.
I have 2 sounds included but disabled. You will need to put them
somewhere for the batch to find it and define them at bottom of file.

It will only work for RAR files in *.part*.rar format but any file name in that collection will work.

It will not overwrite any existing file, and the batch file output will look like it's trying and then
output the error sound -- if you define it -- and keep the DOS output for you to look at.
If the unrar is successful the clapping sound plays and closes the output window (if you define sound).

If you want to use this for right-clicking context menu, this can be used as is
except that the file name is passed in as the 1st parameter, which is ok.

I created a second script to allow a "unrar-HERE" right click option to unrar in same directory.
Change the bat file name to the name you use for the script above.

Code: Select all

@ECHO OFF

:: Parameters expected
:: $1 = The file name to unrar (any in the collection)

echo call c:\bin\unrar-passwd.bat . %1

call c:\bin\unrar-passwd.bat . %1

pause
Exit errorlevel
Enjoy!  :)
ProfDrLuigi
Newbie
Newbie
Posts: 5
Joined: December 20th, 2008, 5:24 am

Re: [REQ] unRAR Script With KNOWN Password.

Post by ProfDrLuigi »

pair of dimes wrote: Try working with this:

OS X / linux: (make sure to "chmod +x scriptname" to make it executable)

Code: Select all

#!/bin/bash
unrar x -idp -o- -p- -p<password> $1 $1

That doesn´t work this way. I find out how to use it under OSX.

Code: Select all

#!/bin/bash
base=`basename $0`
cd "$1"
unrar x -idp -o- -p- -p$base "*.rar" && rm *.rar *.par2 *.PAR2 *.Par2
The "&&" is for deleting the rar-parts & par-parts after successfull unpacking. If unpack fails it lefts the parts untouched. Tested with OSX 10.5
A clou of this script is that you never must edit the script itself. Its enough if you rename the script to the password you need to unpack. The scripts "imports" the filename of itself and put it to the password phrase: "-p$base"

If u need different passwords in your queue simply copy the script with the Finder and rename it and after that choose it as post-script in your queue. And dont forget to choose the "R" Mode.

Have phun. :D

You can DL the script here:
http://www.mediafire.com/?nxejba0jbyr
Last edited by ProfDrLuigi on December 22nd, 2008, 4:21 pm, edited 1 time in total.
ProfDrLuigi
Newbie
Newbie
Posts: 5
Joined: December 20th, 2008, 5:24 am

Re: [REQ] unRAR Script With KNOWN Password.

Post by ProfDrLuigi »

If u have a password:

For example ~pe:ß-;fvä8 9?jtt_o?9!bk*lri:

which has illegal Finder Characters use this script:

Code: Select all

#!/bin/bash
base=`head -n 1 kryptisches-pass.txt`
cd "$1"
unrar x -idp -o- -p- -p$base "*.rar" && rm *.rar *.par2 *.PAR2 *.Par2 
You need a file called "kryptisches-pass.txt" too. In the first line of this file u must enter the passphrase.

Here you can DL the script inclusive txt-file:
http://www.mediafire.com/?s45xlvtkmwm
Post Reply