Sign in to follow this  
Followers 0
WhiteCrow

Automatic .rar and .par

7 posts in this topic

#include <File.au3>
#include <Array.au3>

Dim $filter[99]
Dim $rars[1]
Dim $pars[1]
$n=0
$path=(@ScriptDir)

;MsgBox(0, "", $path)

$filter[0]="*.rar"
$filter[1]="*.part001.rar"
$filter[2]="*.par"

$rar=_FileListToArray($path, $filter[0], 0)
$end=Ubound($rar)

Do
$n=$n+1
$teststring=_ArrayToString($rar, @CR, $n, $n)
$found=StringInStr ($teststring, ".part")

Select
case $found=0
_ArrayAdd ($rars, $teststring)
EndSelect

Until $n=$end
_ArraySort($rars)
_ArrayDelete($rars, 0)
_ArraySort($rars)
$rar=$rars
$n=0

$par=_FileListToArray($path, $filter[2], 0)

$end=Ubound($par)

Do
$n=$n+1
$teststring=_ArrayToString($par, @CR, $n, $n)
$found=StringInStr ($teststring, ".vol")

Select
case $found=0
_ArrayAdd ($pars, $teststring)
EndSelect

Until $n=$end
_ArraySort($rars)
_ArrayDelete($pars, 0)
_ArraySort($pars)
$par=$pars
$n=0

$part01=_FileListToArray($path, $filter[1], 0)

Run ("C:\Program Files\QuickPar\QuickPar.exe" & " " & $path & "\" & $par[1]); this will not work

; .rar is no problem becouse rar.exe handles added filenames with : rar.exe e filename dir_to_extract_to

What this program does, is find al .part001.rar and .rar and .par files in the current directory.

I'm making a automatic unpacking script.

This doesn't work becouse Quickpar doesnt handle added filenames.

What i'm searching for is a command, is that handles files the same way as being double clicked on in explorer.

Then i can make this work B)

Thanks in advance.

PS i'm not an elegant coder.

Share this post


Link to post
Share on other sites



You could do what I do and use either DlDone or rarslave. These can be tricky to find on the internet (especially DlDone), but you can find them in the news groups.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Run (@COMSPEC & ' /c start file.rar' ...)

or

DllCall & ShellExecute & command Open

Try search for it in forum and HelpFile...

Thank you for your reply, alltough i'm provicient at english, its not my native language.

So i didnt know what to search for on the forum and the helpfile, now i do B)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You could do what I do and use either DlDone or rarslave. These can be tricky to find on the internet (especially DlDone), but you can find them in the news groups.

I like to do this in my own script, its a nice exercise B)

But thanks for the help.

I will post the script when its done :o

Edited by WhiteCrow

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You probably have the spaces in path problem. Change the code as follows.

Run('C:\Program Files\QuickPar\QuickPar.exe' & ' "' & $path & '\' & $par[1] & '"'); this will work

Works fine for me after the change.

Did you know that there is a Par2 command line program. Search for Par2Cmd on google or check it out here:

Par2Cmd in Par2 Forums

Post your code as you go along. I am interested in your future plans.

What I would like is for it to sit in the background monitoring for new files, checking them, unpacking them and deleting them when done. That is sort of what DlDone does, but it's user interface is not very clean.

Edited by Stumpii

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Thanks for the advice stumpii, but i figured it out , my script works realy well now :P

It has an ini to store all defaults, im rather proud of it :lmao:

Next thing to do is to add it to the contextmenu of windows..

#include <File.au3>
#include <Array.au3>
Opt("WinTextMatchMode", 2)
Opt("WinSearchChildren", 1)

Dim $filter[6]
Dim $temprar[1]
Dim $temppar[1]
Dim $failed [1]
$count=0
$inifilenpath=@ScriptDir & "\" & "parrar.ini"

$gogogo=1
$gogo=0
$n=0

$DownDir=IniRead ( $inifilenpath, "DownloadBaseDir", "DownDir", "not found" )
if $DownDir="not found" then
    $DownDir=FileSelectFolder ( "What is your most used Downloading directory ?(the root of that)", "")
    IniWrite ( $inifilenpath, "DownloadBaseDir", "DownDir", $Downdir )
endif

$winrarpath=IniRead ( $inifilenpath, "WinRarDir", "WinRar", "not found" )
if $winrarpath="not found" then
    $winrarpath=FileOpenDialog("What is the location of Winrar ?", "", "Rar.exe (Rar.exe)", 1 + 2, "Rar.exe" )
    IniWrite ( $inifilenpath, "WinRarDir", "WinRar", $winrarpath)
endif

$deletedir=IniRead ( $inifilenpath, "DeleteDir", "Delete", "not found" )
if $deletedir = "not found" then
    $yesno=msgbox(4, "Delete or Not", "Do you want PaRRaR to ask if you want to delete the processdir after each run ?" & @CR & "This option also gives you some more stats when your done processing.")
    if $yesno = 6 then
        Iniwrite ( $inifilenpath, "DeleteDir", "Delete", "yes" )
    else
        Iniwrite ( $inifilenpath, "DeleteDir", "Delete", "no" )
    endif
    
    MsgBox(0, "Settings", "Settings Done, written in parrar.ini (same place as parrar.exe)" & @CR & "Change the .ini if you like, or delete parrar.ini to reset the settings, and be asked these questions again.")
endif


$path=FileSelectFolder ( "Wich directory do you want to process the Par and Rar files from ? ", $DownDir)
$deleteyes=$path
$path=StringReplace ( $path, " ", '"' & " " & '"')

$filter[0]="*.rar"
$filter[1]="*.part001.rar"
$filter[2]="*.par"
$filter[3]="*.part01.rar"
$filter[4]="*.part1.rar"
$filter[5]="*.001"

$rar=_FileListToArray($path, $filter[0], 0)

if $rar <> "" then
    
    $end=Ubound($rar)
    Do
        $n=$n+1
        $teststring=_ArrayToString($rar, @CR, $n, $n)
        $found=StringInStr ($teststring, ".part")
        
        Select
            case $found=0
                _ArrayAdd ($temprar, $teststring)
        EndSelect
        
    Until $n=$end -1
    $rar=$temprar
    $n=0
    
endif

$par=_FileListToArray($path, $filter[2], 1)

;_ArrayDisplay ( $par, "pars" )

if $par <> "" then
    
    $end=Ubound($par)
    
    Do
        $n=$n+1
        $teststring=_ArrayToString($par, @CR, $n, $n)
        $found=StringInStr ($teststring, ".vol")
        
        Select
            case $found=0
                _ArrayAdd ($temppar, $teststring)
        EndSelect
        
    Until $n=$end -1
    _ArraySort($temppar)
    $par=$temppar
    $n=0
    
endif

$part001=_FileListToArray($path, $filter[1], 1)

if $part001 <> "" then
    
    $end=Ubound($part001)
    Do
        $n=$n+1
        _ArrayAdd ($rar, $part001[$n])
    Until $n=$end -1
    $n=0
endif

$part01=_FileListToArray($path, $filter[3], 1)
if $part01 <> "" then
    $end=Ubound($part01)
    Do
        $n=$n+1
        _ArrayAdd ($rar, $part01[$n])
    Until $n=$end -1
    $n=0
    
endif

$part1=_FileListToArray($path, $filter[4], 1)

if $part1 <> "" then
    
    $end=Ubound($part1)
    Do
        $n=$n+1
        _ArrayAdd ($rar, $part1[$n])
    Until $n=$end -1
    $n=0
    
endif

$n001=_FileListToArray($path, $filter[5], 1)

if $n001 <> "" then
    
    $end=Ubound($n001)
    Do
        $n=$n+1
        _ArrayAdd ($rar, $n001[$n])
    Until $n=$end -1
    $n=0
    
endif

_ArraySort($rar)
MsgBox(0, "" , $rar[1])

if $rar="" then
    MsgBox(0, "PaRRaR", "No files found to extract.")
    exit
endif


$whereto=FileSelectFolder ( "Where do you want to extract the RAR files to ?", "")
$whereto=StringReplace ( $whereto, " ", '"' & " " & '"')
$whereto= $whereto & '"'

$n=0
$end=Ubound($par)
Do
    
    $n=$n+1
    $teststring=_ArrayToString($par, @CR, $n, $n)
    $found=StringInStr ($teststring, " ")
    
    if $found <> 0 then
        $vari=StringReplace ( $teststring, " ", '"' & " " & '"')
        _ArrayDelete ( $par, $n )
        _ArrayAdd ($par, $vari)
    endif
    
Until $n=$end -1
_ArraySort($par)
$n=0

$end=Ubound($rar)
Do
    
    $n=$n+1
    $teststring=_ArrayToString($rar, @CR, $n, $n)
    $found=StringInStr ($teststring, " ")
    
    if $found <> 0 then
        $vari=StringReplace ( $teststring, " ", '"' & " " & '"')
        _ArrayDelete ( $rar, $n )
        _ArrayAdd ($rar, $vari)
    endif
    
Until $n=$end -1
_ArraySort($rar)
$n=0

if $par <> "" then
    
    $end=Ubound($par)
    Do
        $n=$n+1
        $parpath=$path & "\"
        $parfile=$par[$n] & '"'
        Run (@COMSPEC & " /c " & '"' & "start " & $parpath & $parfile)
        
        Do
            $title = WinGetTitle("QuickPar")
            Sleep(2500)
            
            Select
                Case StringInStr ($title, "All Data Verified") <> 0
                    $gogo=1
                    $gogogo=2
                Case StringInStr ($title, "Repair Succeeded") <> 0
                    $gogo=1
                    $gogogo=2
                Case StringInStr ($title, "blocks") <> 0
                    $gogo=2
                    $gogogo=2
                Case StringInStr ($title, "Select more recovery volumes") <> 0
                    $gogo=2
                    $gogogo=2
            EndSelect
            
        Until $gogogo=2
        $gogogo=1
        $gogo=0
        If $gogo=2 then
            _ArrayAdd ($failed, $par[$n])
        endif
    
        
        Winclose($title)
        Sleep(1000)
    Until $n=$end -1
    $n=0
    
endif


if $rar <> "" then
    $winrarpath=StringReplace ( $winrarpath, " ", '"' & " " & '"')
    $n=0
    $end=Ubound($rar)
    Do
        $n=$n+1
        $rarpath=$path & "\"
        $rarfile=$rar[$n]
        
        
        Run (@COMSPEC & " /c " & '"' & "start " & $winrarpath & " x " & "-o- " & "-- " & $rarpath & $rarfile & " " & $whereto)
            do
            sleep(2500)
        until ProcessExists ( "rar.exe" ) = 0
        
    Until $n=$end -1
    $n=0
    
endif

MsgBox (0, "", "All files Done!", 4)

$yesno=MsgBox(4, "", "Do you want to delete the directory ?" & @CR & $deleteyes )

If $yesno=6 then
    DirRemove ( $deleteyes, 1 )
else
    $msgbox(0, "Allright", "You chose No, directory not deleted", 4)
endif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0