File Compression in XP

Before you start

Objectives: learn how to manage File Compression in XP.

Prerequisites: no prerequisites.

Key terms: folder, compression, attribute, ntfs, file, partition

ZIP vs File Compression

ZIP allows us to create compressed set of files. We can take a bunch of files and compress them into single entity. With File Compression we can compress a file or a folder in Windows directly. When we work with compressed files or folders, Windows will automatically decompress them. When we are finished, Windows will automatically compress them back.

Compressed Attribute

Every file and folder on NTFS partition has a ‘Compressed’ attribute. This attribute can be ‘true’ or ‘false’. Because of that attribute Windows knows which files should be compressed to save disk space. To set this attribute, we can right-click any file or folder, select ‘Properties’, and select ‘Advanced’ on the ‘General’ tab. Here we can check ‘Compress contents to save disk space’ option.

 Compressed Attribute

Image 245.1 – Advanced Attributes

If we set a ‘compression’ attribute to a folder, we have an option to compress all the sub folders and all of the files inside of that particular folder. If we add a new file to that folder, it will also be compressed since it will inherit the compression attribute of that particular folder. If we decide to move that file to another folder on the same partition, the compression attribute will remain set. If we decide to copy that file to another location, the new copy will inherit the compression attribute from the new folder. If we move or copy that file to a different partition, it will always inherit the attributes of the new target folder. In this case, when we move a file, Windows will first create a copy, and once the copy has been verified, Windows will delete the original. Because of that, Windows will see that file as a new file, so it will use the attributes from the new folder to set compression status.

NTFS File System

We can use compression on NTFS file system. If we move a compressed file to the non-NTFS partition, the file will be uncompressed. We can not use compression and encryption together. We cannot save or copy a compressed folder or file to a disk containing less free space than the real size of the folder or file when they are uncompressed. NTFS compression on volumes with cluster sizes larger than 4 KB is not supported. If we copy or move a zipped folder, it always remains zipped (regardless of the destination file system).

CMD Tools

We can use a ‘Compact.exe‘ for compression, which is a Command Prompt tool. We can use the following switches with ‘compact’:/C to compress the specified files (folders are marked as compressed), /S to compress all sub folders of the specified folder, /U to uncompress the specified files (folders are marked as uncompressed). The following example command will compress all files in the ‘Great citations’ folder (including subfolders).

compact /C C:\Documents and Settings\Administrator\My Documents\Great citations\*.* /S

Example Configuration

To compress a file or folder, we have to navigate to the file or folder that we want to compress. In our example, we will navigate to the ‘My Documents’ folder, and then select ‘Great citations’ folder.

Great Citations Folder

Image 245.2 – Great citations Folder

Let’s right-click that folder, select ‘Properties, click on the ‘Advanced’ button, and then select ‘Compress content to save disk space’.

General Tab

Image 245.3 – General Tab

 Advanced Attributes

Image 245.4 – Commpress Attribute Checked

Click OK. The system will ask us do we want to apply changes to this folder only, or to the folder and all of its subfolders.

Confirm Attribute Changes

Image 245.5 – Confirm Attribute Changes

We will apply this changes to this folder, subfolders and files. Let’s click OK. We can also see our compressed files in blue color if we want. To do that, go to the Tools menu, select ‘Folder Options’, go to the ‘View’ tab, and scroll down. Check the ‘Show encrypted or compressed NTFS files in color’, and click ‘OK’.

Folder Options

Image 245.6 – Tools Menu

View Tab

Image 245.7 – View Tab

Let’s uncompress a file. To do that, let’s open the ‘Great citations’ folder, right click on the ‘Seneca – On Providence’ file, select ‘Properties, and click on the ‘Advanced’ button. To uncompress a file we need to clear the check box for ‘Compress contents to save disk space’, and click OK. Notice the color change.

 Uncompressed File

Image 245.8 – Uncompressed File

We would do the same thing for our compressed folders.


ZIP compression and NTFS File Compression are two different things. Every file and folder on NTFS file system has a Compression attribute which we use to set compression on or off. In XP we set compression attribute by checking the ‘Compress contents to save disk space’ option.