如何在Windows NTFS中使用压缩命令在文件系统级别压缩文件和文件夹?

Windows modern file system NTFS provides some compression mechanisms to gain more space in disks and partitions. This compression operation is done mainly with compact command. This command do not directly compress the files as we stated in the start compression operation is done by NTFS file system in the file system level. So we do not see any change in the file and folder names and behaviors. This command simply change file system related compression attributes and the compression will be done by operating system file system part in a appropriate time automatically.

Windows现代文件系统NTFS提供了一些压缩机制来获取磁盘和分区中的更多空间。 该压缩操作主要通过compact命令完成。 此命令不会直接压缩文件,正如我们在开始压缩操作中所述的那样,是由NTFS文件系统在文件系统级别完成的。 因此,我们看不到文件和文件夹名称以及行为的任何变化。 该命令仅更改文件系统相关的压缩属性,压缩将由操作系统文件系统部分在适当的时间自动完成。

帮帮我 (Help)

Help about compact command can be printed like below.

可以如下打印有关compact命令的帮助。

$ compact /?
Help
Help
帮帮我

句法(Syntax)

Syntax of the compact command is very same with the most the windows commands.

大多数Windows命令中的compact命令的语法都非常相似。

compact [option] [file/directory]

显示压缩信息 (Display Compression Information)

We may need the current situation of the working directory compression status. We will get information about compressed files, the compression ratio and how much space we have gained from file system level compression. We will only issue the compact command to list current directory compression information like below.

我们可能需要当前工作目录压缩状态的情况。 我们将获得有关压缩文件,压缩率以及从文件系统级压缩获得多少空间的信息。 我们只会发出compact命令来列出当前目录压缩信息,如下所示。

$ compact
Display Compression Information
Display Compression Information
显示压缩信息

As we can see all files size information like before compression and after compression is listed. In this example we can clearly see that there is no compressed file. We can understand this from compression ratio which is 1.0 for all files.

如我们所见,列出了压缩之前和压缩之后的所有文件大小信息。 在此示例中,我们可以清楚地看到没有压缩文件。 我们可以从所有文件的压缩率为1.0来理解这一点。

压缩率 (Compression Ratio)

Ratio is used to score space saving in number. Higher ratio means more spaces and savings in our disk. We want to save a lot of space in our disks. We can not change the ratio in a easy way. Ratio is determined by files data types.

比率用于对节省空间的数字进行评分。 更高的比率意味着更多空间并节省磁盘空间。 我们想在磁盘上节省很多空间。 我们不能轻易改变比率。 比率由文件数据类型确定。

LEARN MORE  Linux Chown Command Tutorial
了解更多Linux Chown命令教程

Following files have more compressible data

以下文件具有更多可压缩数据

  • Text

    文本
  • Office Document

    办公文件
  • Recurring Data

    重复数据

Following files have less compressible data

以下文件的可压缩数据较少

  • Binary

    二元
  • Picture

    图片
  • Movie

    电影
  • Pdf

    聚甲醛

压缩档案(Compress File)

The first example about compression is compressing a single file. This command will set the  files compress attributes true. We will use /C option to compress given file.

有关压缩的第一个示例是压缩单个文件。 此命令将文件的compress属性设置为true。 我们将使用/C选项压缩给定文件。

$ compact /c users.txt
Compress File
Compress File
压缩档案

We can see from output the current size of the file which is 47 byte and the compression ratio which is 1 because we recently set to compress.

从输出中我们可以看到文件的当前大小为47字节,压缩比为1因为我们最近设置为compress。

压缩所有文件 (Compress All Files)

We can set enable the compression for all current working directory files by using * (asterisk) for file name. This will assume the command will be executed for all files.

我们可以通过使用* (星号)作为文件名来为所有当前工作目录文件设置启用压缩。 这将假定将对所有文件执行该命令。

$ compact /c *

压缩所有文件和子目录文件 (Compress All Files and Sub Directory Files)

Compression attrbutes can be set enable for a given directories all sub directories and folders with /s option. We call this recursively. This is the most used version of the compact command. This option gives the ability to work and compress files as a bulk.

可以使用/s选项为给定目录的所有子目录和文件夹设置压缩属性。 我们将其递归地称为。 这是compact命令最常用的版本。 此选项使您能够批量处理和压缩文件。

In this example we will compress all sub-directories and files in cygwin64 directory in a recursive manner.

在此示例中,我们将以递归方式压缩cygwin64目录中的所有子目录和文件。

$ compact /s /c cygwin64
Compress All Files and Sub Directory Files
Compress All Files and Sub Directory Files
压缩所有文件和子目录文件

After issuing command the command is executed in a recursive manner as we can see from output.

发出命令后,该命令将以递归方式执行,正如我们从输出中看到的那样。

解压文件 (Uncompress File)

Up to now we have compressed or set the compression attributes of the files. In some situations compression by file system can create some headache  for us. So we may need to disable the file system level compression for a file. We can disable compression for a file by providing the /u option like below.

到目前为止,我们已经压缩或设置了文件的压缩属性。 在某些情况下,文件系统压缩会给我们带来一些麻烦。 因此,我们可能需要禁用文件的文件系统级压缩。 我们可以通过提供/u选项来禁用文件压缩,如下所示。

LEARN MORE  What Is SSD (Solid State Drive)?
了解更多什么是SSD(固态硬盘)?

In this example we will turn off compression for file named users.txt

在此示例中,我们将关闭对名为users.txt文件的压缩

$ compress /u users.txt
Uncompress File
Uncompress File
解压文件

解压缩所有文件(Uncompress All Files)

We can also turn off compression for all files in the current working directory too.

我们也可以关闭当前工作目录中所有文件的压缩。

$ compress /u *

解压缩所有文件和子目录文件 (Uncompress All Files and Sub Directory Files)

We can also change the compression attributes of all files currently located in current working directory and childs as recursively. We can accomplish this task like below.

我们还可以递归地更改当前位于当前工作目录和子目录中的所有文件的压缩属性。 我们可以像下面那样完成此任务。

$ compress /u /s *

翻译自: https://www.poftut.com/how-to-compress-files-and-folders-in-file-system-level-with-compact-command-in-windows-ntfs/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值