Batch file extracting all files from nested archives

I have managed to leverage a powerful
forfiles command line utility with the mighty
7z compression program.
Below is a simple batch file extracting all files from nested archives hidden at any depth inside other archives and/or folders. After the extraction each archive file turns into a folder having the archive file name. If, for example, there was an "outer.rar"
archive file containing nothing but an "inner.zip" archive with only "afile.txt" inside, "outer.rar" becomes "...\outer.rar\inner.zip\afile.txt" file system path.
@echo off
rem extract_nested_archives.bat
move %1 "%TMP%"\%2
md %2
7z x -o%1 -y %TMP%\%2
del "%TMP%"\%2
for %%a in (zip rar jar z bz2 gz gzip tgz tar lha iso wim cab rpm deb) do forfiles /P %1 /S /M *.%%a /C "cmd /c if @isdir==FALSE extract_nested_archives.bat @path @file"
ARCHIVES ARE DELETED DURING THE EXTRACTION! Make a copy before running the script!
"7z.exe" and "extract_nested_archives.bat" should be in folders available via the %PATH% environment variable.
The first parameter of extract_nested_archives.bat is the full path name of the archive or folder that should be fully expanded; the second parameter is just the archive or folder name without the path. So you should run "c:\temp\extract_nested_archives.bat
c:\temp\outer.rar outer.rar" from the command line to completely expand "outer.rar". "c:\temp" must be the current folder.
Best regards, 0x000000AF

Incredibly useful!  Thank you so much.  I did make a couple of small changes to make the script a little easier to use from the end-user perspective.
First - I don't like making the user input the redundant second parameter, so I added this snippet which extracts it from the first parameter.  The first line of the snippet enables delayed expansion so that special characters in our file name don't
break anything.  The second line pulls the parameter into a variable, and the 3rd line uses delayed expansion on that new variable.  Before implementing delayed expansion I had problems with file paths which included parentheses.
SetLocal EnableDelayedExpansion
Set SOURCE=%1
For %%Z in (!source!) do (
set FILENAME=%%~nxZ
set FILENAME=%FILENAME:"=%
Anyway once that was done, I just used %FILENAME% everywhere in the script instead of
%2 (making sure to correct quotes as needed)
This way, to run my script all you need to run is:
C:\temp\extract_nested_archives.bat C:\temp\Archive.zip
Second - I didn't want to modify the Windows environment variable.  So I replaced
7z with "%PROGRAMFILES%\7-zip\7z.exe"
I also replaced extract_nested_archives.bat with "%~f0" (which represents the full path+filename of the current script).
Here is my full script now.  Tested on Windows 8 with the 64-bit version of 7-zip installed:
@echo off
Setlocal EnableDelayedExpansion
Set source=%1
For %%Z in (!source!) do (
set FILENAME=%%~nxZ
set FILENAME=%FILENAME:"=%
move /Y %1 "%TMP%\%FILENAME%"
md "%FILENAME%"
"%PROGRAMFILES%\7-zip\7z.exe" x -o%1 -y "%TMP%\%FILENAME%"
DEL "%TMP%\%FILENAME%"
for %%a in (zip rar jar z bz2 gz gzip tgz tar lha iso wim cab rpm deb) do (
forfiles /P %1 /S /M *.%%a /C "cmd /c if @isdir==FALSE "%~f0" @path @file"

Similar Messages

  • I have to extract all files from a hard drive of a macbook pro that is no longer working. All I have to access the hard drive is a PC, is this possible, and if so how?

    I have to extract all files from a hard drive of a macbook pro that is no longer working. All I have to access the hard drive is a PC, is this possible, and if so how?

    You could try Paragon HFS+ for Windows. That would allow you to read and write files from a Mac-formatted drive.
    Clinton

  • Best way to extract all images from Messages?

    My iPad freaked out earlier today and unfortunately I had to do a recovery and restore (from iCloud backup).  I say unfortunately because I was 90% certain I was not backing up photos/video (and there was no way to check before doing the restore).  And indeed I had photo/video backup turned off.
    I'm mostly back to normal now, except for all the lost photos/videos.  I've gone through some of Messages to Save ones I sent there. 
    What is the best way to extract all images from past Messages so I don't have to tediously load earlier messages?   I understand there are some programs that allow one to go through a local backup and go through messages.  But for this I suppose I'd first need to make a local backup of everything, no?  Are those programs able to extract just images I've sent or do they grab everything (i.e. images others have sent me?)
    Related, before I did the initial restore could I have easily retrieved the photos/images on the device through some third-party solution?
    Lastly, and semi-off topic.. What determines the image name for an image in Messages?   For example, I Copied a photo someone sent me via Messages and Pasted it three times back to her (all at the same time).   The image filenames are IMG_6447.jpg,  IMG_4820.jpg, IMG_0291.jpg.  

    Thanks Kirby.  I utilize Aperture 3 by reference instead of a compiled library.  So I have individual folder/projects stored on my laptop.  By exporting as a library, does Aperture bring these folders and related images "with it"?
    What I don't want to lose is any post processing I do in the field which creates separate versions and/or .PSD files.
    Thanks for your continued assistance.
    Chris

  • Extract all attachments from .eml file

    Hi
    I have a .eml file saved to disk.
    I want to extract all attachments that it contains into separate files.
    Can anyone help me regarding this issue?
    Thanks

    Hi,
    Did you had already success extracting the attachments from .eml File?
    I'm also looking how to do this, but have not much success yet.
    Thank you,
    Stefan

  • How to extract all files from several folders?

    I want to extract all the files from about 20 folders
    Is there a simple way to do this ?

    my computer was recently formated and I lost all my itunes library. I had all my music on my ipod, but I couldn't sync it, so I had to google for a backup to itunes program. I found copytrans and was very surprised to see how easy it was! I thought I had to do the whole thing from scratch! I just love this app!

  • How do I clear the " view all files " history in Adobe Reader XI  I have recent files set to 1 "View all files " shows all files from 22 june to current date

    as i indicated in my question I'm having a problem clearing the " view all files " history in Adobe Reader XI

    My current Ver is 11.0.07   and the"view all recent files" selection is found by clicking on file and in the drop down menu it is the selection just above the list of recent files

  • I can´t extract all raws from dng

    A year ago I started converter my ARW (sony raw) and after my NEF (nikon RAW) files to DNG with embedded raw, now Iwant to edit the dng in DxO pro 5 and it dosen´t read it, I try to get theoriginal raw and I only recovered as 60 percent of the original raws, thishappened to me in several batches of pictures and in different mac computers, I update the DNG converter 5.4 and is the same. Can sombody help me?

    The file structure shows the embedded native raw file, but the DNG Converter can not extract it (it says none is there). I tried it with six different versions of the DNG converter (the oldest from 2005), none has managed it.
    I noticed, that you have edited this file by LR/ACR or PS/ACR. What about the other DNGs, from which you can not extract the raw file? Have they too been edited? Or see it from the other side: have those been edited, from which you can extract the raws? I tested this and did not find any problem: I converted a raw file in DNG and embedded the raw; copied, and edited one of them. Afterwards I could extract the raw from both DNGs. Thus this does not appear to be a hot line.
    I don't have any other idea. However, I suggest you never to embed the raw files in the DNG but to save/archive them on their own.
    Sorry for the trouble.
    Gabor

  • Extracting all values from multiple menus

    Hello all,
    Basically I have a jsp that consists of three of what FrontPage calls drop down boxes but I will hereafter call list boxes, each containing a number of options extracted from a database; these values can be moved from one box to another using java script. When I hit a submit button I wish to be able to extract all the values from two of these lists and add them into a database. I know how to extract selected values but I need all the values of both lists regardless of what the user selects and I need the contents of each kept distinct.
    Any help provided will be appreciated and I apologize if this question is something all the forum vets have already seen before.
    Philip

    Only the values that are selected will be submitted
    with the form. So, add a call to your form tag's
    onSubmit event to call a function like this:<form name='myForm' onsubmit='selectAll()'>
    <script language='javascript'>
    function selectAll() {
    for(i=0; i<myForm.mySelectList.options.length; i++)
    myForm.mySelectList.options.selected = true;
    // do the same for the other two select lists
    </script>
    Thanks for the tip, but unfortunately this means that the two list boxes that I want will become intermingled. Is there a way to keep the information in the two lists seperate?
    Philip                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • HT201210 the iPhone 4 will not connect through iTunes and has extracted all data from the device

    It seems like this could be an issue with the device.  IT will not connect long enough to extract the data.

    From the Community Ettiquette page found here.
    1) Post only technical support questions and answers, unless otherwise noted.
    2) Be polite, constructive and stay on topic.
    3) Search for questions similar to your own before submitting a new question to the community.
    I'm certain if you try option 3 you'll find relevant information on how to proceed.

  • Is there a way to Extract all formulas from Crystal Reports files?

    Hi:
    I have about 40 Crystal Reports (.rpt files).  I need to go through each one and look at formulas if a certain variable/value is used since it has currently changed.  It is taking way too long and not to mention inefficent to open each file, look through any place where there could be custom formulas such as when to suppress - etc.  Is there are way to easily exact all custom formulas from all those report into say a Text file so I can do a Search for it?  That would be the easiest way to find what I'm looking for.
    I have Crystal Reports XI.
    Thanks in advance for your help.

    One option is to use a tool such as rptInspector.  See: [http://www.softwareforces.com/Product/ri/pro/3/rptInspector.htm|http://www.softwareforces.com/Product/ri/pro/3/rptInspector.htm]

  • How Do I Extract All Pages From A Pdf File and Turn Them All Into Separate Files

    Hi i have  downloaded 100 reports into a single pdf, that must be extracted into 100 seperate pdfs. A prety straightforward question, that i was not able to find a straighforward answer to.
    Thanks for your help in advance!
    Matt

    i have Adobe Acrobat Pro, Version 10, would that work?
    Mind you, I want to take the 100 pages and turn them into 100 pdf files, avoiding of course going through the process of doing it one page at a time, one page at a time, one hundred times lol

  • Process file after file / not all files at the same time

    Hi There,
    i have a new Problem with our XI Systems.
    We process XML Files.. they come in a folder on the Server.. from there the Engine takes it and processes the message.
    This works so:
    In the folder /xyz/ comes a XML File... File1.xml
    After 2 Minutes the XI System takes the messages and proccess it. The Engine then move the file to Folder /archive/
    Another two minutes later a new file comes in to the Folder /xyz/ File2.xml
    File2.xml change now data that comed with File1.xml
    and two minutes later the Engine processes the message
    and so on and on....
    My problem is now.. when i put File1.xml and File2.xml in the Folder /xyz/ at the same time.. the Engine processes the Messages at the same time.. and inconsistencys comes into my system.
    So what i want is:
    I Put File1.xml and File2.xml into the same folder.. then the Engine comes and Process first File1.xml and when this finished the System proccesses File2.xml
    Do you know what i mean?
    Eventually someone has a solution for my question?
    Thanks
    Bjoern

    OK. I found now in the INtegration Builder the Point as you can see in the Screenhot here:
    http://img253.imageshack.us/my.php?image=58047457ux6.jpg
    But my Problem is that i dont know exactly which queue i have to take..
    In SXMB_ADM i found the following queues:
    http://img253.imageshack.us/my.php?image=57846606uq4.jpg
    And in the SXMB_MONI i see the following for messages:
    http://img111.imageshack.us/my.php?image=47303569tg7.jpg
    From the screenshots above, can you tell me which queue i have to take?
    Or did i have to take the Queue that comes automatically when i choose EOIO?!
    Thanks 
    Bjoern
    Edited by: bjoern bayerschmidt on Dec 18, 2008 2:17 PM

  • Flat file extraction with FILE

    Hi BWers,
    I want to extract a flat file to BW with an infopackage.
    This flat file is located in a physical path changing according to the system :
    - in the developpment server, path is :
    ...\dev\file.csv
    - in the quality server, path is :
    ...\qual\file.csv
    - in the production server, path is :
    ...\prod\file.csv
    In the Name of the File into the infopackage extraction tab, i have to put the physical path or the logical file or routine.
    I don't want to put directly the physical path, because i would have to change this path in qual and prod servers.
    I don't want too to use a routine.
    So I created a logical file with FILE T-code. But in physical path i put :
    ...\dev\<FILENAME>
    How to put a directory variable like that : $(director)<filename> which says : if we are in Dev, so $directory =
    ...\dev\file, else qual...
    Thanks for help.
    Cheers,

    Hi,
    Here is the answer i found:
    Use in  FILE\Assignment of Physical Paths to Logical Path the variable like that:
    <V=Z_INT_SRV>
    Declare this variables in Definition of Variables.
    Z_INT_SRV

  • Moving a message to another file: not all files are listed by "MOVE": how do I get a local file shown on the left of the screen onto the move command list?

    I have some 20 "local" files, but when I want to copy or move a mailing only about half of these are listed as possible destinations. Why are some of then hidden and how can I get the full list to appear in the Move (or the Copy) window?

    I can't reproduce that here. I get a whole folder tree to explore.
    However, I prefer to use QuickFolderMove.
    It turns the '''right-click|Move To''' pop-out into a MRU list along with a text entry box so you seek a folder by entering all or part of its name. The beauty of this is that it doesn't care which folder or account the target folder is in. The downside is that you need to have a pretty clear idea of the name of the folder you're looking for.
    https://addons.mozilla.org/en-US/thunderbird/addon/quick-folder-move/?src=api

  • How to extract all tcodes from a particluar User Group

    Folks,
    I need to derive all the tcodes that are associated with a particular User Group. I have tried various options under SUIM and have also checked many tables such as TSTC and USR02 and many more. But none of them just list out tcodes for a User group. Can some one help ? Thanks !

    Hi Karthik,
    I don't think you can directly find out the t-codes that are associated with a particular user group.You have to concatenate a few tables in order to find the same.
    1.You will need to find out the list of users belonging to the user group first.
    Go to USR02
    Enter * in the user name field,
    Enter the name of the user group,
    Execute - This will give u the list of users belonging to an user group
    2.Find the list of roles that are associated with these users.
    Go to AGR_USERS
    In the user field upload the list of users
    Execute - This will give the list of roles that are associated with these users.
    3.Find the t-codes that are contained in the list of above roles.
    Go To AGR_1251
    Upload the list of roles there,
    In the field Object, Enter S_TCODE
    Execute - This will give u the desired output i.e  t-codes that are associated with a particular user group.
    Thanks,
    Saby..

Maybe you are looking for

  • WAS JAVA add-in for ABAP install error on AIX Oracle

    Hi All I am currently trying to install a 640 WAS JAVA add-in for ABAP on AIX 5.2 running oracle 9.2.0.6 for SAP 4.7 SR1. I have successfully installed the ABAP stack, however, when I try to install the JAVA add-in, I get an error on step "Start SAP

  • BITC Timecode in Final Cut Pro 4.5

    Does anyone know how to create burnt in timecode to a rough cut edit to show my clients. I am sure this is straight forward. Please help!!! Dual 2.0 G5   Mac OS X (10.3.9)  

  • A Second Page for Podcasting

    Question: I already have a blog through iWeb. I want to start a podcasting page for my church's sermons. I designed it in iWeb and don't know how to upload it so that it can be accessed via iWeb. Does iWeb allow you to have multiple web pages? MacBoo

  • PSE 7 stopped launching

    I have PSE 7 it has stopped lauching - Why? I've had it for years and no problem with it. I have tried all round about ways to launch it (like rt clicking a jpeg and saying for PSE 7 to edit it) nothing works. I've gone directly to the shortcuts targ

  • Problem with data in Cube 0IC_C03 in Bex Query

    Hi, (1) I am loading data into cube 0ic_c03 from data sources 2LIS_03_BX,2LIS_03_BF and 2LIS_03_UM. I need one more field <b>Manufacturing date</b> in my cube. (2) That's why I enhanced datasource 2LIS_03_BF, and populated HSDAT (Manufacturing date f