How To Compress Files and Folders In File System Level With Compact Command In Windows NTFS?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-compress-files-and-folders-in-file-system-level-with-compact-command-in-windows-ntfs/
PINTEREST
PINTEREST
INSTAGRAM

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 behaviours. 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.

Help

Help about compact command can be printed like below.

$ compact /?

Help
Help

Syntax

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

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.

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.

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  How To Make Directory in Python?

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 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.

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.

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.

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

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.

LEARN MORE  Find Directory In Linux

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

Uncompress File
Uncompress File

Uncompress All Files

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

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.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-compress-files-and-folders-in-file-system-level-with-compact-command-in-windows-ntfs/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.