在 Windows 系统上通过命令行压缩文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9714712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compressing files through command line on a Windows system
提问by Jash
I am trying to compress one folder on my local disk, for example: C:\Templates
我正在尝试压缩本地磁盘上的一个文件夹,例如: C:\Templates
I am using the below command from command line (cmd.exe) to do this operation:
我正在使用命令行(cmd.exe)中的以下命令来执行此操作:
compact /c C:\Templates
But it is not working, and shows the following message:
但它不起作用,并显示以下消息:
1 files within 1 directory were compressed.
0 total bytes of data are stored in 0 bytes.
The compression ratio is 1.0 to 1.
My machine is running Windows 7, 64 bit.
我的机器运行的是 64 位 Windows 7。
回答by Habib
Use:
用:
compact /c /s:C:\Templates
The only thing you are missing is the /s
switch before the directory name.
您唯一缺少的是/s
目录名称之前的开关。
回答by Mark Fraser
Are you sure the directory isn't empty? It will give that message on empty directories. Future files put there will be compressed.
你确定目录不是空的?它将在空目录上给出该消息。以后放在那里的文件会被压缩。
回答by Eric
BTW, using compact.exe will not workif cluster size is larger than 4096 bytes. I formatted a drive with a 8192-byte cluster size, and later found out that NTFS compression doesn't work with it.
顺便说一句,如果簇大小大于 4096 字节,则使用 compact.exe 将不起作用。我用 8192 字节的簇大小格式化了一个驱动器,后来发现 NTFS 压缩不适用于它。