我可以在没有扩展名的 zip 文件上使用 PowerShell `Expand-Archive` [英] Can I use PowerShell `Expand-Archive` upon a zip file with no extension

查看:27
本文介绍了我可以在没有扩展名的 zip 文件上使用 PowerShell `Expand-Archive`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个 PowerShell 脚本,我必须从删除扩展名的 .zip 存档中提取内容,因此,存档的名称不是 test.zip 但只是 test,它被压缩为 .zip 存档.我正在尝试为此目的使用 PowerShell cmdlet Expand-Archive,如下所示:

I'm working upon a PowerShell script, where I have to extract the content out of a .zip archive which extension is removed, so, archive's name is let's say not test.zip but just test, and it is compressed as a .zip archive. I'm trying to use for this purpose the PowerShell cmdlet Expand-Archive like shown below :

Expand-Archive -LiteralPath "Path to the archive" -DestinationPath "Extraction Path"

但是,它似乎不起作用,是否有可能使用 powershell 提取此存档的内容,或者最好使用诸如 7zip 命令行工具或类似工具之类的解决方法?

But, it doesn't seem to work, is there a possibility of extracting this archive's content with powershell, or it would be better to use a work around like 7zip command line tools, or something similar?

推荐答案

Expand-Archive cmdlet 旨在显式处理具有 .zip 扩展名的路径.您可以通过使用 Copy-Item 创建具有适当扩展名的存档副本或使用 Rename-Item 重命名存档以具有扩展名(使用 <如果带有扩展名的存档已经存在并且您想覆盖它,则 code>Move-Item 可能更可取;Rename-Item 无法覆盖).

The Expand-Archive cmdlet is designed to explicitly work with a path that has a .zip extension. You can work around this by either creating a copy of your archive with a proper extension using Copy-Item or renaming the archive to have an extension with Rename-Item (using Move-Item may be more desirable if the archive with extension already exists and you want to overwrite it; Rename-Item is not capable of overwriting).

这篇关于我可以在没有扩展名的 zip 文件上使用 PowerShell `Expand-Archive`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆