BigBadWeirdo Posted June 26, 2005 Posted June 26, 2005 (edited) I wrote a little script that will automaticly fix rar's or other stuff with use of PAR2 files and QuickPar. So see the attachment and tell me if i did a good or a bad job on writing it expandcollapse popup#include <process.au3> #include <file.au3> If MsgBox(1, "Warning!", "This program only works on PAR files downloaded to sub-dir's!"_ & @CRLF & "So if you download all your crap to one giant dir, then hit cancel because this won't work for you!") = 2 Then Exit If FileExists(@ScriptDir & "\quickfix.cfg") Then $file = FileOpen(@ScriptDir & "\quickfix.cfg",0) $quickpar_dir = FileReadLine($file) $root = FileReadLine($file) FileClose($file) Else If FileExists(@ProgramFilesDir & "\QuickPar\QuickPar.exe") Then $quickpar_dir = @ProgramFilesDir & "\QuickPar" Else Do $quickpar_dir = InputBox("Directory Input", "Please input the directory to your quickpar application:","") If StringRight($quickpar_dir,1) = "\" Then $quickpar_dir = StringTrimRight($quickpar_dir,1) EndIf Until DirGetSize($quickpar_dir) <> -1 EndIf Do $root = InputBox("Directory Input", "Please input your root download directory:","") If StringRight($root,1) = "\" Then $root = StringTrimRight($root,1) EndIf Until DirGetSize($root) <> -1 $file = FileOpen("quickfix.cfg",2) FileWriteLine(@ScriptDir & "\quickfix.cfg",$quickpar_dir) FileWriteLine(@ScriptDir & "\quickfix.cfg",$root) FileClose($file) EndIf $temp_file = $root & "\temp.txt" _RunDOS("dir " & $root & "\ /A:D /B > " & $temp_file) Dim $pardirs _FileReadToArray($temp_file,$pardirs) FileDelete($temp_file) For $a = 1 To $pardirs[0]-1 $temp = FileFindFirstFile($root & "\" & StringStripWS($pardirs[$a],3) & "\*.par2") If $temp = -1 Then ContinueLoop(1) While 1 $file = FileFindNextFile($temp) If @error Then FileClose($temp) ExitLoop(1) EndIf If FileExists($root & "\" & StringStripWS($pardirs[$a],3) & "\" & $file) = 0 Then ContinueLoop(1) Run($quickpar_dir & "\QuickPar.exe " & '"' & $root & "\" & StringStripWS($pardirs[$a],3) & "\" & $file & '"') WinWait("QuickPar - ") While 1 Sleep(100) If WinExists("QuickPar - Repair Succeeded") Or WinExists("QuickPar - All Data Verified") Then WinClose("QuickPar - ") FileDelete($root & "\" & StringStripWS($pardirs[$a],3) & "\" & $file) If StringInStr($file,"+")>0 And StringIsDigit(StringMid($file,StringInStr($file,"+") - 1,1)) And StringIsDigit(StringMid($file,StringInStr($file,"+") + 1,1)) Then While StringRight($file,1) <> "+" $file = StringTrimRight($file,1) WEnd While StringRight($file,1 <> "." $file = StringTrimRight($file,1) WEnd Else $file = StringTrimRight($file,4) EndIf FileDelete($root & "\" & StringStripWS($pardirs[$a],3) & "\" & $file & "*PAR2") FileOpen($root & "\" & StringStripWS($pardirs[$a],3) & "\" & $file & "VERIFIED",2) ExitLoop(1) ElseIf WinExists("QuickPar - Need") Then WinClose("QuickPar - ") ExitLoop(1) EndIf WEnd WEnd Next Edited June 26, 2005 by BigBadWeirdo
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now