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

查看:125
本文介绍了我可以在没有扩展名的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的扩展名(如果具有扩展名的存档已经存在并且更容易使用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天全站免登陆