由于Windows资源管理器(至少从Windows XP开始)对ZIP文件有一些基本的支持,似乎应该有一个命令行对应,但我似乎找不到任何迹象。
Windows(XP、Vista、7、8、2003、2008、2013)是否有内置的命令行压缩工具,或者我是否需要坚持使用第三方工具?
它没有内置于Windows中,但它在资源包工具中作为 "COMPRESS"。
C:\>compress /?
Syntax:
COMPRESS [-R] [-D] [-S] [ -Z | -ZX ] Source Destination
COMPRESS -R [-D] [-S] [ -Z | -ZX ] Source [Destination]
Description:
Compresses one or more files.
Parameter List:
-R Rename compressed files.
-D Update compressed files only if out of date.
-S Suppress copyright information.
-ZX LZX compression. This is default compression.
-Z MS-ZIP compression.
Source Source file specification. Wildcards may be
used.
Destination Destination file | path specification.
Destination may be a directory. If Source is
multiple files and -r is not specified,
Destination must be a directory.
例子。
COMPRESS temp.txt compressed.txt
COMPRESS -R *.*
COMPRESS -R *.exe *.dll compressed_dir
Powershell做到了。见。