Jump to content


Photo

Batch Par2 Help, CODE PROVIDED


  • Please log in to reply
15 replies to this topic

#1 justusiv

justusiv
  • Members
  • 90 posts

Posted 03 June 2006 - 11:36 PM

Here is what i have so far. Its a batch Par2 program. It recursivly searches for par2 files runs them then takes the appopriate approach when the outcome is known for the par2.
FileSelectFolder, OutputVar, , 3  ;This allows you to select what folder you will do a recursive search in later.
if OutputVar =   ;if cancelled it exits the script
	ExitApp
else
{
	Loop, %OutputVar%\*.par2, , 1   ;this is the loop that finds all the *.par2 files
	{
		IfNotInString, A_LoopFileFullPath, .vol   ;par files have vol files this excludes running any of the volume files
		{
			Run, %A_LoopFileFullPath% ;this runs the par2 fils from before
			loop
			{
				IfWinExist, QuickPar - All Data Verified  ;this happens if par2 is complete and no repair is needed
				{
					WinWait, QuickPar - All Data Verified
					WinActivate
					send !e  ;this will exit quickpar when it is done
					sleep, 250
					break
				}
				IfWinExist, QuickPar - Repair Succeeded  ;this happens if par2 is complete and the repair is done
				{
					WinWait, QuickPar - Repair Succeeded
					WinActivate
					send !e  ;this will exit quickpar when it is done
					sleep, 250
					break
				}
				IfWinExist, QuickPar - Need ;this happens if par2 is complete and the repair can not be completed. i would like to move the folder where the par2 is contained and all the files also
				{
				WinWait, QuickPar - Need
				WinActivate
				send !e   ;this will exit quickpar when it is done
				sleep, 250
;*********THIS IS WHERE I NEED HELP**********   ;quickpar exited so the files are not in use anymore
;I AM HAVING TROUBLE MAKING THIS HAPPEN
;C:\EXAMPLE\EXAMPLE\DOWNLOAD\THISDIR
;should be moved to
;C:\EXAMPLE\EXAMPLE\DOWNLOAD\INCOMPLETE\THISDIR
:*********END OF HELP SECTION************
				break
				}
			}
		}
	}
msgbox Completed recursive scan for all par2 files
}
return


#2 corrupt

corrupt
  • Members
  • 2558 posts

Posted 04 June 2006 - 12:20 AM

You're not going to be able to move the directory if the file(s) are in use and running (unless I'm misunderstanding)...

#3 justusiv

justusiv
  • Members
  • 90 posts

Posted 04 June 2006 - 12:52 AM

I actually closed the quickpar after it finds out it doesnt have enough blocks to repair the files. No files or folders would be in use at the point where i added the comments.
send !e
            sleep, 250
;*********THIS IS WHERE I NEED HELP**********
the Send !e is what closes quick par.
If i need to commment my entire code i would be more then happy to. I actually decompiled it so i lost its comments

#4 corrupt

corrupt
  • Members
  • 2558 posts

Posted 04 June 2006 - 02:38 AM

If i need to commment my entire code i would be more then happy to. I actually decompiled it so i lost its comments

Yes please. I'm not sure I understand but it looks as though you are trying to move the entire directory conditionally when you are in the middle of parsing the files contained in it...

#5 justusiv

justusiv
  • Members
  • 90 posts

Posted 04 June 2006 - 03:14 AM

I will comment the code really quick. But i kinda missed the important part of this program. It uses Quickpar to do all the par2 checking.


EDIT
Sorry i am not good at commenting : /

#6 jonib

jonib
  • Members
  • 75 posts

Posted 05 June 2006 - 12:40 AM

Hi justusiv

If I understood what you want this might help.
OutputVar=Download ; Path to scan
Loop, %OutputVar%\*.par2, , 1
{
	Loop, Parse, A_LoopFileDir , \ 
		ParDir=%A_LoopField% ; Get the last part of the path
	IfNotInString, A_LoopFileDir, \INCOMPLETE\ ; Check that the par2 file is not in the "INCOMPLETE" directory
	{
		FileMoveDir, %A_LoopFileDir%, %OutputVar%\INCOMPLETE\%ParDir% ; Move the dir to the "INCOMPLETE" directory
	}
}


#7 help

help
  • Guests

Posted 24 February 2008 - 04:02 AM

1st part is working nicely
last tip ist not working does nothing

#8 jonib

jonib
  • Members
  • 75 posts

Posted 24 February 2008 - 04:25 AM

1st part is working nicely
last tip ist not working does nothing

If the "last tip" is my code? how did you test it?

#9 help

help
  • Guests

Posted 24 February 2008 - 04:07 PM

i placed your code between the first one that works

;*********THIS IS WHERE I NEED HELP********** ;quickpar exited so the files are not in use anymore
;I AM HAVING TROUBLE MAKING THIS HAPPEN
;C:\EXAMPLE\EXAMPLE\DOWNLOAD\THISDIR
;should be moved to
;C:\EXAMPLE\EXAMPLE\DOWNLOAD\INCOMPLETE\THISDIR
:*********END OF HELP SECTION************

i am total noob

#10 jonib

jonib
  • Members
  • 75 posts

Posted 24 February 2008 - 11:49 PM

OK when you include my code the "OutputVar=Download ; Path to scan" line was not suppose to be included it was so I could test it.

I modified the FileMoveDir command so it would move the file even if the directory that the file was in already was in the INCOMPLETE directory.

Here is my code including the original code that works for me.
FileSelectFolder, OutputVar, , 3  ;This allows you to select what folder you will do a recursive search in later.
if OutputVar =   ;if cancelled it exits the script
   ExitApp
else
{
   Loop, %OutputVar%\*.par2, , 1   ;this is the loop that finds all the *.par2 files
   {
      IfNotInString, A_LoopFileFullPath, .vol   ;par files have vol files this excludes running any of the volume files
      {
         Run, %A_LoopFileFullPath% ;this runs the par2 fils from before
         loop
         {
            IfWinExist, QuickPar - All Data Verified  ;this happens if par2 is complete and no repair is needed
            {
               WinWait, QuickPar - All Data Verified
               WinActivate
               send !e  ;this will exit quickpar when it is done
               sleep, 250
               break
            }
            IfWinExist, QuickPar - Repair Succeeded  ;this happens if par2 is complete and the repair is done
            {
               WinWait, QuickPar - Repair Succeeded
               WinActivate
               send !e  ;this will exit quickpar when it is done
               sleep, 250
               break
            }
            IfWinExist, QuickPar - Need ;this happens if par2 is complete and the repair can not be completed. i would like to move the folder where the par2 is contained and all the files also
            {
            WinWait, QuickPar - Need
            WinActivate
            send !e   ;this will exit quickpar when it is done
            sleep, 250
;*********THIS IS WHERE I NEED HELP**********   ;quickpar exited so the files are not in use anymore
;OutputVar=Download ; Path to scan
Loop, %OutputVar%\*.par2, , 1
{
   Loop, Parse, A_LoopFileDir , \
      ParDir=%A_LoopField% ; Get the last part of the path
   IfNotInString, A_LoopFileDir, \INCOMPLETE\ ; Check that the par2 file is not in the "INCOMPLETE" directory
   {
      FileMoveDir, %A_LoopFileDir%, %OutputVar%\INCOMPLETE\%ParDir%, 2 ; Move the dir to the "INCOMPLETE" directory
   }
}
;*********END OF HELP SECTION************
            break
            }
         }
      }
   }
msgbox Completed recursive scan for all par2 files
}
return
Hope this helps.

jonib

#11 help

help
  • Guests

Posted 25 February 2008 - 12:45 AM

hey first let me thank you for helping me

this one works like the first script
but it does not move anything incomplete in a incomplete dir

#12 jonib

jonib
  • Members
  • 75 posts

Posted 25 February 2008 - 12:54 AM

Do you have an "INCOMPLETE" named directory in the same directory you choose to scan?

When I run the script it moves any directory in the scan directory with .par2 files to the INCOMPLETE directory.

jonib

#13 help

help
  • Guests

Posted 25 February 2008 - 01:09 AM

ahhh i see thats was my mistake
but is it doable to make a directory inside every folder that ist called incomplete ?

anyway your solution is the best, thank you soo much

greets
nerdzone

#14 jonib

jonib
  • Members
  • 75 posts

Posted 25 February 2008 - 01:29 AM

My last complete code wont work correctly it would move all directory's containing .par2 files.

FileSelectFolder, OutputVar, , 3  ;This allows you to select what folder you will do a recursive search in later.
if OutputVar =   ;if cancelled it exits the script
   ExitApp
else
{
   Loop, %OutputVar%\*.par2, , 1   ;this is the loop that finds all the *.par2 files
   {
      IfNotInString, A_LoopFileFullPath, .vol   ;par files have vol files this excludes running any of the volume files
      {
         Run, %A_LoopFileFullPath% ;this runs the par2 fils from before
         loop
         {
            IfWinExist, QuickPar - All Data Verified  ;this happens if par2 is complete and no repair is needed
            {
               WinWait, QuickPar - All Data Verified
               WinActivate
               send !e  ;this will exit quickpar when it is done
               sleep, 250
               break
            }
            IfWinExist, QuickPar - Repair Succeeded  ;this happens if par2 is complete and the repair is done
            {
               WinWait, QuickPar - Repair Succeeded
               WinActivate
               send !e  ;this will exit quickpar when it is done
               sleep, 250
               break
            }
            IfWinExist, QuickPar - Need ;this happens if par2 is complete and the repair can not be completed. i would like to move the folder where the par2 is contained and all the files also
            {
            WinWait, QuickPar - Need
            WinActivate
            send !e   ;this will exit quickpar when it is done
            sleep, 250
;*********THIS IS WHERE I NEED HELP**********   ;quickpar exited so the files are not in use anymore
					 	Loop, Parse, A_LoopFileDir , \
								ParDir=%A_LoopField% ; Get the last part of the path
					 	IfNotInString, A_LoopFileDir, \INCOMPLETE\ ; Check that the par2 file is not in the "INCOMPLETE" directory
					 	{
								FileMoveDir, %A_LoopFileDir%, %OutputVar%\INCOMPLETE\%ParDir% ; Move the dir to the "INCOMPLETE" directory
						}
;*********END OF HELP SECTION************
            break
            }
         }
      }
   }
msgbox Completed recursive scan for all par2 files
}
return
This one should work better.

but is it doable to make a directory inside every folder that ist called incomplete ?

I don't know why not.
Try this.
FileSelectFolder, OutputVar, , 3  ;This allows you to select what folder you will do a recursive search in later.
if OutputVar =   ;if cancelled it exits the script
   ExitApp
else
{
   Loop, %OutputVar%\*.par2, , 1   ;this is the loop that finds all the *.par2 files
   {
      IfNotInString, A_LoopFileFullPath, .vol   ;par files have vol files this excludes running any of the volume files
      {
         Run, %A_LoopFileFullPath% ;this runs the par2 fils from before
         loop
         {
            IfWinExist, QuickPar - All Data Verified  ;this happens if par2 is complete and no repair is needed
            {
               WinWait, QuickPar - All Data Verified
               WinActivate
               send !e  ;this will exit quickpar when it is done
               sleep, 250
               break
            }
            IfWinExist, QuickPar - Repair Succeeded  ;this happens if par2 is complete and the repair is done
            {
               WinWait, QuickPar - Repair Succeeded
               WinActivate
               send !e  ;this will exit quickpar when it is done
               sleep, 250
               break
            }
            IfWinExist, QuickPar - Need ;this happens if par2 is complete and the repair can not be completed. i would like to move the folder where the par2 is contained and all the files also
            {
            WinWait, QuickPar - Need
            WinActivate
            send !e   ;this will exit quickpar when it is done
            sleep, 250
;*********THIS IS WHERE I NEED HELP**********   ;quickpar exited so the files are not in use anymore
					 	Loop, Parse, A_LoopFileDir , \
								ParDir=%A_LoopField% ; Get the last part of the path
					 	IfNotInString, A_LoopFileDir, \INCOMPLETE ; Check that the par2 file is not in the "INCOMPLETE" directory
					 	{
					 			FileCreateDir, %A_LoopFileDir%\INCOMPLETE
								FileMove, %A_LoopFileDir%\*, %A_LoopFileDir%\INCOMPLETE\ ; Move the files to the "INCOMPLETE" directory
						}
;*********END OF HELP SECTION************
            break
            }
         }
      }
   }
msgbox Completed recursive scan for all par2 files
}
return

jonib

#15 nerdy1 help

nerdy1 help
  • Guests

Posted 25 February 2008 - 10:04 AM

yippie i just test the last one , superb, again thank you jonib