Welcome Guest.   Make a donation to an author on the site October 25, 2014, 02:09:42 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2014! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: [DISCUSSION] How to extract embedded zip/rar files recursively in one step?  (Read 7102 times)
vixay
Supporting Member
**
Posts: 137



ViXaY

see users location on a map View Profile Give some DonationCredits to this forum member
« on: September 13, 2006, 06:32:24 AM »

This has been bugging me for a while...
Often when you dowload something it is compressed multiple times and is very annoying to extract.
e.g.
[copy or print]
xx.zip
-yy1.zip
--yy1.rar
---zz.exe
-yy2.zip
--yy2.rar
---zz.exe
-yy3.zip
--yy3.rar
---zz.exe
So for the above case which shows the directory structure of xx.zip file. Now how can i extract zz.exe in one step, without having to first extract xx.zip, then all yy#.zip, then yy#.rar?

I have beel looking everywhere! Unrar can extract embedded files, but not split embedded files... don't ask me to explain, try it yourself.

anybody have any ideas/suggestions?

Actually i figured out one script that works for me
[copy or print]
@echo OFF

SET "dir=."
SET "ext=*.zip"

winRAR x -o+ %1

FOR /r "%dir%" %%* IN (%ext%) DO (
  winRAR x -o+ "%%*" "%%~dp*"
  del "%%*"
  )

winrar x -r -o+ *.part1.rar
del /s *.part?.rar

but this works only for a specific case (i.e. where you have an archive in which you have zip files in which you have rar files)
can it be improved to work for all cases?
« Last Edit: September 13, 2006, 06:57:50 AM by vixay » Logged

"Drunk on the Nectar of Life!" -me
AbteriX
Charter Honorary Member
***
Posts: 1,050


Member #520

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: September 13, 2006, 09:31:19 AM »

Allways the same structure?

Maybe with an batch.cmd:
C:\>UNPACK *.zip  INTO STEP1
CD STEP1
C:\STEP1>UNPACK *.zip INTO STEP2
CD STEP2
C:\STEP1\STEP2>UNRAR *.rar INTO STEP3
CD STEP3
C:\STEP1\STEP2\STEP3>EXTRAXT *.exe INTO STEP4
... to be continue
Logged

Greetings, Stefan.
vixay
Supporting Member
**
Posts: 137



ViXaY

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: September 14, 2006, 02:02:08 AM »

Actually, no. That's the whole point! I want something that works with all cases (not a specific case)
The script i provided works for a specific case of zip/rar(zip(rar)))

And i want to preserve the directory structure, and remove the intermediate files.

So let me restate my objective: Extract all archives from within an archive (passed parameter) and/or directory (i.e. recursive), while preserving directory structure and deleting intermediate files generated.

Save the following code in a batch file with the name extract3levels.cmd
[copy or print]
@echo OFF
REM //Set up some variables
SET "dir=."
SET "ext=*.zip"

REM //Extract the passed file, to current directory
REM //overwriting files.
winRAR x -o+ %1
REM //Should have a graceful error case here to make sure the operation completed
REM //successfully, if not then exit script... how to do this?

REM //Now in the current directory extract each zip file into its folder
REM //Delete the file after extracting it
FOR /r "%dir%" %%* IN (%ext%) DO (
  winRAR x -o+ "%%*" "%%~dp*"
  del "%%*"
  )

REM //Now search for a file ending with part1.rar in all subdirectories and extract it
winrar x -r -o+ *.part1.rar
REM //Delete all files ending with a part?.rar in all subdirectories
del /s *.part?.rar

REM Usage:
REM program_name <archive>

 the above script works, but maybe what i want needs a more flexible language, maybe autohotkey can do this...?
« Last Edit: September 14, 2006, 02:06:22 AM by vixay » Logged

"Drunk on the Nectar of Life!" -me
Cloq
Charter Member
***
Posts: 250

View Profile Give some DonationCredits to this forum member
« Reply #3 on: September 14, 2006, 01:16:20 PM »

Hmm.. Total Commander handles that for me. Since it "opens" archives as directories/folders, all you have to do is keep pressing enter/clicking on it till you get to the actual file. Then you can drag/copy it out to the desktop (or wherever) or to the other windowpane. So far I have tested with multi-level combinations of zips and rars nest in each other, 6 archive deep.
Logged
vixay
Supporting Member
**
Posts: 137



ViXaY

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #4 on: September 15, 2006, 02:01:28 AM »

Hmm.. Total Commander handles that for me. Since it "opens" archives as directories/folders, all you have to do is keep pressing enter/clicking on it till you get to the actual file. Then you can drag/copy it out to the desktop (or wherever) or to the other windowpane. So far I have tested with multi-level combinations of zips and rars nest in each other, 6 archive deep.

That's ok. Even winrar can do that. with only 1 archive embeded (no matter how many levels) it is ok to do this, but what about when you have 5 archives in 1 archive, and then in those 5 archives you have 1 archive each, but that 1 archive is a split archive... so to extract the files, you need to get all those 5 archives hidden within each of those split archives and then extract them.. sigh, i guess i am not making much sense, let me see if i can whip up a sample for you...

Logged

"Drunk on the Nectar of Life!" -me
EĆ³in
Charter Member
***
Posts: 1,400


O'Callaghan

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: September 15, 2006, 04:22:57 AM »

How often do you actually encounter stuff like this? I've no doubt its very annoying but it must be very rare, and isn't it illogical as solid archiving would achieve better compression than this sort of nested archiving.

That said though I don't know of any program to help you, sorry.
Logged

Interviewer: Is there anything you don't like?
Bjarne Stroustrup: Marketing hype as a substitute for technical argument. Thoughtless adherence to dogma. Pride in ignorance.
vixay
Supporting Member
**
Posts: 137



ViXaY

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #6 on: September 15, 2006, 06:51:28 AM »

How often do you actually encounter stuff like this? I've no doubt its very annoying but it must be very rare, and isn't it illogical as solid archiving would achieve better compression than this sort of nested archiving.

That said though I don't know of any program to help you, sorry.

No problem! Thanks anyway.
I was just trying to plumb the intellect of the donationcoder community to figure out if there was a better way to do this other than what I've found so far. (which i am sure there is)
Obsessed with making things easy & simple, and a programmer, i figured there oughta be a way.
As for frequency, you are right it isn't that often, maybe once or twice a week. No doubt the logic is unfathomable, regardless that is what one recieves and one has to try and improve where one can.

Anyway thinking of all this has made me think that maybe i ought to write the psuedocode and maybe that will help explain what i need.

[copy or print]
Examine passed file/directory
Process each file
 if not archive, skip //base case, exit condition
 elseif archive
   extract all files with path into a subdir $temp$, overwriting existing files
   set flag $extracted$
if flag $extracted$
  call self with $temp$ //recursive call
  delete archive(s) in $temp$ //remove temp archives as they should be extracted by now

// there should probably be some ending code to move extracted files from $temp$ to directory of the orginal archive

I forget if this is an in-order, pre-order, or post-order traversal recursive algorithm http://en.wikipedia.org/wiki/Tree_search. But i think that should do the trick. Though, the important thing is to extract all level 1s first, then process the next level, as only then will split archives be handled appropriately.
« Last Edit: September 15, 2006, 06:58:42 AM by vixay » Logged

"Drunk on the Nectar of Life!" -me
Cloq
Charter Member
***
Posts: 250

View Profile Give some DonationCredits to this forum member
« Reply #7 on: September 15, 2006, 05:33:51 PM »

That's ok. Even winrar can do that. with only 1 archive embeded (no matter how many levels) it is ok to do this, but what about when you have 5 archives in 1 archive, and then in those 5 archives you have 1 archive each, but that 1 archive is a split archive... so to extract the files, you need to get all those 5 archives hidden within each of those split archives and then extract them.. sigh, i guess i am not making much sense, let me see if i can whip up a sample for you...

Would you be able to upload a sample archive (filled with dummy text archives) with the above mentioned structure with it?
Logged
vixay
Supporting Member
**
Posts: 137



ViXaY

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #8 on: September 18, 2006, 02:32:35 AM »

That's ok. Even winrar can do that. with only 1 archive embeded (no matter how many levels) it is ok to do this, but what about when you have 5 archives in 1 archive, and then in those 5 archives you have 1 archive each, but that 1 archive is a split archive... so to extract the files, you need to get all those 5 archives hidden within each of those split archives and then extract them.. sigh, i guess i am not making much sense, let me see if i can whip up a sample for you...

Would you be able to upload a sample archive (filled with dummy text archives) with the above mentioned structure with it?

Here ya go! Some random text file...

* Test Archive.zip (45.09 KB - downloaded 188 times.)
Logged

"Drunk on the Nectar of Life!" -me
lanux128
Global Moderator
*****
Posts: 6,109



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: September 18, 2006, 03:08:02 AM »

vixay:
from the structure you presented, it seems that you need a tool like Rarslave or other similar Usenet binary tools.
Logged

vixay
Supporting Member
**
Posts: 137



ViXaY

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #10 on: September 19, 2006, 04:00:25 AM »

vixay:
from the structure you presented, it seems that you need a tool like Rarslave or other similar Usenet binary tools.

Hmm... didn't work out with the test archive... i guess it ignores it because its a zip.... even after disabling the RAR only flag it doesnt' work...
Logged

"Drunk on the Nectar of Life!" -me
wr975
Charter Member
***
Posts: 369



View Profile Give some DonationCredits to this forum member
« Reply #11 on: September 19, 2006, 05:58:42 AM »


I wrote a AHK script for myself once + integrated it in 2xplorer. So I just click a button and all archives in the folder get unpacked. Perhaps it's of use for you? It unpacks all archives in a folder in a subfolder (archive-name).

Installation: paste code in notepad, edit the second line pointing to winrar.exe, save as whatever.ahk, install authotkey (autohotkey.com)

Usage: Copy sourcefolder in clipboard and launch the script, or pass the sourcefolder as first parameter. An optional second parameter would be a targetfolder (where to place unpacked files).

Limitation: Some (rare) RAR names makes it to mess up. Didn't figure that out yet.


AHK Code:
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.041s | Server load: 0.1 ]