The file is "Target.zip". 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
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 Target.zip "TargetNMD21-2022Renewal.xlsm" tar: Error opening archive: Failed to open 'Target.zip'
>7z e -i!%"TargetNMD21-2022Renewal.xlsm"% Target.zip -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: Target.zip Path = Target.zip 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 "Target.zip" "TargetNMD21-2022Renewal.xlsm" -d "Target"
-j junks paths. The following works as desired, so i have a usable solution.
>unzip "Target.zip" "TargetNMD21-2022Renewal.xlsm" -d "Target"
Would be cool to get solutions for 7z and tar.
Source: Windows Questions