How to Extract Individual Files from a Zip Using Tar, Info-Zip, or 7z?

  7zip, info-zip, tar, windows, zip

The file is "". The top-level folder inside the zip is "Target". The desired file, "Renewal.xlsm", is at a deeper level. The directory tree in the zip should be duplicated for the uncompressed file.

I cannot use Scripting.FileSystemObject (scrrun.dll), Windows Script Host (wshom.ocx), or Microsoft Shell Controls (shell32.dll). Those aren’t good for my need, because they are asynchronous. Therefor, most similar questions on SO won’t help, and are not duplicates. I haven’t found my answer in those threads.

The following doesn’t work:


>tar -zxvf "TargetNMD21-2022Renewal.xlsm"
tar: Error opening archive: Failed to open ''


>7z e -i!%"TargetNMD21-2022Renewal.xlsm"% -o*
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Scanning the drive for archives:
1 file, 5896214 bytes (5759 KiB)
Extracting archive:
Path =
Type = zip
Physical Size = 5896214
No files to process
Everything is Ok
Files: 0
Size:       0
Compressed: 5896214


This extracts the file, but i don’t get the directory-tree on the output.

>unzip -j "" "TargetNMD21-2022Renewal.xlsm" -d "Target"

Update: -j junks paths. The following works as desired, so i have a usable solution.

>unzip "" "TargetNMD21-2022Renewal.xlsm" -d "Target"

Would be cool to get solutions for 7z and tar.

Source: Windows Questions