My Eclipse and Maven development environments are using a different directory structure, such that if I export my results into a JAR / ZIP file, the required directories are included, but at the wrong directory location.
我的Eclipse和Maven开发环境使用不同的目录结构,因此,如果我将结果导出到JAR/ZIP文件中,则会包含所需的目录,但目录位置错误。
Is there a way, in a PowerShell script on Windows, to move directories within a ZIP file?
在Windows上的PowerShell脚本中,有没有一种方法可以移动ZIP文件中的目录?
If relevant, you may assume that 7-Zip is installed on the system.
如果相关,您可以假设系统上安装了7-Zip。
更多回答
优秀答案推荐
There are a variety of PowerShell modules such as 7Zip4Powershell that can help using libraries such as 7-Zip from PowerShell easier.
有各种PowerShell模块,如7Zip4Powershell,可以帮助更容易地使用PowerShell中的7-Zip等库。
However, moving a single file inside of a Zip file is easy with just 7-Zip. Here is an example:
然而,只需7-Zip就可以轻松地在Zip文件中移动单个文件。以下是一个示例:
& "T:\Program Files\7-Zip\7z.exe" rn MyWebApp.zip DirOne\SomeClass.jar DirTwo\SomeClass.jar
The above command will move SomeClass.jar from the DirOne directory to the DirTwo directory inside of the MyWebApp.zip.
上面的命令将SomeClass.jar从DirOne目录移动到MyWebApp.zip中的DirTwo目录。
Of course if you need to move more than just one file then you could use 7Zip4Powershell to get a list of file names to move:
当然,如果您需要移动多个文件,那么您可以使用7Zip4Powershell来获取要移动的文件名列表:
Install-Module 7Zip4Powershell
Import-Module 7Zip4Powershell
Get-7Zip MyWebApp.zip | ? FileName -match '^DirOne\\' | % {
& "T:\Program Files\7-Zip\7z.exe" rn MyWebApp.zip $_.FileName ($_.Filename -replace "DirOne", "DirTwo")
}
更多回答
我是一名优秀的程序员,十分优秀!