使用Windows(10) powerShell ise,是否可以像使用命令“Compress-Archive”那样压缩文件夹的内容,但不能将其封装在压缩的根文件夹中?
(在zip的根目录中获取文件)
- myFolder { index.html,mycss.css,myConn.php}
使用的命令:-DestinationPath C:\wamp64\www\myFolder\myZip.zip -Path C:\wamp64\www\myFolder
实际领事t在myZip.zip:{- myFolder { index.html,mycss.css,myConn.php} }
期望结果 in myZip.zip:{ index.html,mycss.css,myConn.php}
ps:我试过搜索选项,但没有找到。
发布于 2018-07-24 08:16:16
当您的-Path
是一个文件夹时,您可以显式地将它包含在归档文件中。
正如Tomalak已经提到的,给出通配符会改变这一点。
Compress-Archive -Path C:\wamp64\www\myFolder\* -DestinationPath C:\wamp64\www\myFolder\myZip.zip
如果按正确的位置顺序提供参数,则不必命名它们:
Compress-Archive C:\wamp64\www\myFolder\* C:\wamp64\www\myFolder\myZip.zip
要更好地控制归档的内容,可以通过管道将源管道传输到压缩存档中。
(例如,排除可能的子目录)
Get-ChildItem C:\wamp64\www\myFolder\* -File | Compress-Archive C:\wamp64\www\myFolder\myZip.zip
发布于 2018-07-24 08:00:36
实现此目标的Compress-Archive -DestinationPath C:\wamp64\www\myFolder\myZip.zip -Path C:\wamp64\www\myFolder\*
完整命令
https://stackoverflow.com/questions/51493090
复制相似问题