7zip--How To Extract Subfolders and Subfiles from a zip file


  1. Posts : 186
    Windows 10 Pro x64 21H2
       #1

    7zip--How To Extract Subfolders and Subfiles from a zip file


    I'm trying to use Ketarin to create a portable rescue drive. I'm trying to figure out a way to extract Complete Internet Repair with it's full structure, minus the main folder in the zip file which is named "ComIntRep_{version}." The main files and folders are in the ComIntRep folder, but with each update, that folder name is going to change. I was hoping that there is a way to extract everything within the ComIntRep folder while still maintaining the original structure.

    Here is the code I use to extract everything, including the ComIntRep folder:

    Code:
    7z x "{file}" -o"{root}SyMenu\ProgramFiles\Complete Internet Repair\" -y
    del /q "{root}SyMenu\ProgramFiles\Complete Internet Repair\*.zip"
    Here is what the structure of the original zip looks like:

    7zip--How To Extract Subfolders and Subfiles from a zip file-bandizip_2018-08-21_11-52-35.png

    All I want to do is extract the Docs folder, Language folder, Themes folder, the exe files, and the ini file into my output directory. With the code that I have, the output directory looks like this:
    "{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep_3950"

    I'm at a loss on what I need to do. Any help would be greatly appreciated.
      My Computer


  2. Posts : 3,274
    Win10
       #2

    You can add filters at the end of your 7z command to include only certain folders and files during extraction.

    First make a backup of your files in case this doesn't work out!
    ONLY then try something along this line


    7z.exe x -r -aoa "{file}" -o"{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep_3950" "Docs" "Language" "Themes" *.exe *.ini

    This will extract only the Docs, Language and themes folders as well as only the exe and ini files.

    ( For ref. my version is: 7zip version 18.5.0.0.. Also check the commands and switches for yourself in the 7zip help files. )
      My Computers


  3. Posts : 30,603
    Windows 10 (Pro and Insider Pro)
       #3

    Why don't you just grab a folder /with mouse) and drag it to desired location?
      My Computers


  4. Posts : 186
    Windows 10 Pro x64 21H2
    Thread Starter
       #4

    AndreTen said:
    Why don't you just grab a folder /with mouse) and drag it to desired location?
    That would defeat the purpose of clicking the "Update All" button in Ketarin and having it do the work for me. Isn't that the point of a computer? Make it do all of the work?
      My Computer


  5. Posts : 186
    Windows 10 Pro x64 21H2
    Thread Starter
       #5

    das10 said:
    You can add filters at the end of your 7z command to include only certain folders and files during extraction.

    First make a backup of your files in case this doesn't work out!
    ONLY then try something along this line


    7z.exe x -r -aoa "{file}" -o"{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep_3950" "Docs" "Language" "Themes" *.exe *.ini

    This will extract only the Docs, Language and themes folders as well as only the exe and ini files.

    ( For ref. my version is: 7zip version 18.5.0.0.. Also check the commands and switches for yourself in the 7zip help files. )
    Thanks! I'll give it a shot. The problem is the ComIntRep folder won't be named 3950 when it updates. Is there wildcard support for this command?

    EDIT: This still extracted everything into the ComIntRep_3950 folder.

    I think it has something to do with the {file} part of the command. I just don't know what to put instead of {file}.
      My Computer


  6. Posts : 3,274
    Win10
       #6

    Because the archive filename gets changed after every version update, I think the only way to make your method work is by using a fixed folder name for your output folder such as
    "{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep" instead of
    "{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep_3950"

    Then you would eliminate the need for any wildcards in your output folder (which I don't know is doable or not). The only disadvantage would be that you would not get any version number information from just looking at the folder name. The source archive "{file}" parameter is correct, and then the command every time would be:

    7z.exe x -r -aoa "{file}" -o"{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep" "Docs" "Language" "Themes" *.exe *.ini

    Again, ONLY try this method after backing up your files to see if it works or not.
      My Computers


  7. Posts : 186
    Windows 10 Pro x64 21H2
    Thread Starter
       #7

    das10 said:
    Because the archive filename gets changed after every version update, I think the only way to make your method work is by using a fixed folder name for your output folder such as
    "{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep" instead of
    "{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep_3950"

    Then you would eliminate the need for any wildcards in your output folder (which I don't know is doable or not). The only disadvantage would be that you would not get any version number information from just looking at the folder name. The source archive "{file}" parameter is correct, and then the command every time would be:

    7z.exe x -r -aoa "{file}" -o"{root}SyMenu\ProgramFiles\Complete Internet Repair\ComIntRep" "Docs" "Language" "Themes" *.exe *.ini

    Again, ONLY try this method after backing up your files to see if it works or not.
    I kind of thought that the Complete Internet Repair was my fixed folder name--or at least my goal was to make it my fixed folder. I do fear that I can't achieve what I want because the command I'm looking for doesn't exist or is only supported in another app (e.g., Powershell). I was thinking about making a bat file to run once the zip is extracted, but the Ketarin tool--to my knowledge--is technically mimicking a bat file, so it wouldn't fix my issue, plus I would still have the issue with not being able to rename the version-named folder.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:47.
Find Us




Windows 10 Forums