gpt4 book ai didi

Move files within a ZIP archive [closed](移动ZIP存档中的文件[已关闭])

转载 作者:bug小助手 更新时间:2023-10-22 18:05:08 26 4
gpt4 key购买 nike




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。


更多回答

This question has been discussed on meta: meta.stackoverflow.com/q/426511

这个问题已经在meta上讨论过了:meta.stackeoverlow.com/q/426511

优秀答案推荐

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")
}

更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com