Board logo

标题: [文本处理] 批处理打包压缩文件夹的问题 [打印本页]

作者: netdzb    时间: 2021-7-9 06:55     标题: 批处理打包压缩文件夹的问题

主目录下面有很多文件夹001,002,003......
现在需要对文件夹分别打包成001.zip,
002.zip,003.zip......应该怎么写?
如果主目录下已经存在001.zip,就不要对001这个文件夹压缩了。
作者: newswan    时间: 2021-7-9 11:47

powershell
  1. Get-ChildItem '.\New folder\' -Directory | ForEach-Object {
  2.     if (-not (test-path ($_.name + ".zip")))
  3.     {
  4.         Compress-Archive -path $_.fullname -DestinationPath ($_.name + ".zip")
  5.     }
  6. }
复制代码

作者: netdzb    时间: 2021-7-9 15:21

回复 2# newswan

谢谢,我去学习一下。原来这个也可以用powershell来完成啊~




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2