With Windows(10) powerShell ise, Is it possible to zip the content of a folder, like it does with command 'Compress-Archive', but not encapsuled it in a root folder on th zip ?
(Get the files at root in the zip)
eg: - myFolder { index.html, mycss.css, myConn.php}
used command : -DestinationPath C:\\wamp64\\www\\myFolder\\myZip.zip -Path C:\\wamp64\\www\\myFolder
actual resul t in myZip.zip: { - myFolder { index.html, mycss.css, myConn.php} }
desired result in myZip.zip: { index.html, mycss.css, myConn.php}
ps: i tried search options for that but not found.
Compress-Archive -DestinationPath C:\\wamp64\\www\\myFolder\\myZip.zip -Path C:\\wamp64\\www\\myFolder\\*
完成此目标的完整命令
With your -Path
being a folder you explicitly include it in the archive.
As already mentioned by Tomalak giving a wildcard changes that.
Compress-Archive -Path C:\wamp64\www\myFolder\* -DestinationPath C:\wamp64\www\myFolder\myZip.zip
If you supply the parameters in the proper positional order, you don't have to name them:
Compress-Archive C:\wamp64\www\myFolder\* C:\wamp64\www\myFolder\myZip.zip
To have better control over what is archived you can pipe the source(s) to Compress-Archive
(for example to exclude possible subdirectories)
Get-ChildItem C:\wamp64\www\myFolder\* -File | Compress-Archive C:\wamp64\www\myFolder\myZip.zip
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.