How to partially extract a folder from a 7z file using powershell

会有一股神秘感。 提交于 2019-12-12 18:01:11

问题


I'm trying to automate the install of my platform. I've made a script for compressing the build of the deployables to a 7zip file.

Now i need to uncompress partially some folders to a specific destination.

Package
-app1
--folder11
---folder111
--folder12
-app2
--folder21
--folder22
...

I need to create a powershell script to extract the content of 'app1' to a destination folder.

I've been trying to use the following command but the result is not the as i expected. I've been receiving the full path and not the content from folder11 recursivelly.

Set-Alias zip $ZipCommand
zip x $FilePath app1\folder11 -oc:DeployableFolder -r

Any ideas? Suggestions?

Thanks.


回答1:


I tried and had no issue.

set-alias zip "c:\Program Files\outils\7-Zip\7z.exe"
zip x program.7z python-core-2.6.1\lib -oc:\data

I eventually got a c:\data\python-core-2.6.1 which only contains the lib folder with all its subfolders & files.

The only difference I see is the backslash \ in the output path.

HTH



来源:https://stackoverflow.com/questions/12195959/how-to-partially-extract-a-folder-from-a-7z-file-using-powershell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!