批处理文件:使用Windows压缩压缩文件夹或文件 [英] Batch file : Compress folder or file using windows compress

查看:818
本文介绍了批处理文件:使用Windows压缩压缩文件夹或文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



有没有人知道将文件夹压缩到压缩文件的命令行?就像在我们的默认Windows操作系统上一样,即使我们没有安装第三方软件进行压缩,我们也可以通过右键单击文件夹/文件压缩文件夹并发送到 - >压缩(拉链)



是否可以压缩文件夹?我不想安装任何第三方软件来压缩。我想使用Windows压缩。如果有人在这里知道这个链接,请给我..tq:)

解决方案

如果你真的想在不使用任何第三方压缩工具的情况下这样做,只需批处理,您就可以使用Windows脚本宿主(WSH):

http://en.wikipedia。 org / wiki / Windows_Script_Host [ ^ ]。 />


您可以找到大量的代码示例,这只是其中之一: http://stackoverflow.com/questions/11100696/how-to-compress-in-a-batch-file [ ^ ]。



此脚本的批处理文件样本只有一行(如果你不认识它):

 CScr ipt zip.vbs C:\ test3 C:\ someomeArchive.zip 





您也可以通过PowerShell轻松使用WSH,而无需使用VBScript或JavaScript:

http://en.wikipedia.org/wiki/Powershell [ ^ ]。



如果您对如何使用PowerShell感兴趣,我需要一些时间来查找参考资料,所以请询问一下。



< DD> -SA


Hi all,

Does anyone know the command line to compress a folder to zip? Like on our default Windows OS, even we don''t install 3rd party software to compress, we also can compress the folder by right click the folder/file and Send To --> Compressed (Zipped)

Is it possible to compress the folder? I don''t want to install any 3rd party software to compress. I want to use Windows Compressed. If anyone here know the link, kindly give me..tq :)

解决方案

If you really want to do it without using any 3-rd party compress utility, with just the batch, you can use Windows Script Host (WSH):
http://en.wikipedia.org/wiki/Windows_Script_Host[^].

You can find a good number of code samples, this is just one of them: http://stackoverflow.com/questions/11100696/how-to-compress-in-a-batch-file[^].

The sample of batch file for this script is just one line (in case you did not recognize it):

CScript zip.vbs C:\test3 C:\someArchive.zip



You can also easily use WSH through PowerShell, without using VBScript or JavaScript:
http://en.wikipedia.org/wiki/Powershell[^].

If you are interested how to do it with PowerShell, I''ll need some time to find a references, so please ask about it.

—SA


这篇关于批处理文件:使用Windows压缩压缩文件夹或文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆