Lesson 1: Managing Compression

Lesson 1:?Managing Compression

Windows XP Professional supports two types of compression: NTFS compression and Compressed Folders. NTFS compression enables you to compress files, folders, or an entire drive. NTFS compressed files and folders occupy less space on an NTFS-formatted volume, which enables you to store more data. Each file and folder on an NTFS volume has a compression state, which is either compressed or uncompressed. The Compressed Folders feature allows you to create a compressed folder so that all files you store in that folder are automatically compressed.


After this lesson, you will be able to

  • Manage disk compression
  • Compress and uncompress files, folders, and NTFS volumes

Estimated lesson time: 60 minutes


Using Compressed Folders

The Compressed Folders feature is new in Windows XP Professional and provides the ability to create compressed folders and view their contents. The Compressed Folders feature in Windows XP Professional allows you to compress large files so that you can store more files on a floppy disk or hard drive.

To create a compressed folder, start Windows Explorer, click File, click New, and then click Compressed Folder. This creates a compressed folder in the current folder. You can drag and drop files into the compressed folder and the files are automatically compressed. If you copy a file from the compressed folder to another that is not compressed, that file will no longer be compressed. A zipper icon is shown, marking compressed folders (see Figure 14.1), and these folders are labeled Compressed Folder.

Figure 14.1??A compressed folder showing the zipper icon

Benefits of using compressed folders generated with the Compressed Folders feature include the following:

  • You can create and use compressed files and folders on both file allocation table (FAT) and NTFS volumes.
  • You can open files directly from the compressed folders and you can run some programs directly from compressed folders.
  • You can move these compressed files and folders to any drive or folder on your computer, the Internet, or your network and they are compatible with other zip programs.
  • You can encrypt compressed folders that you created using this feature.
  • You can compress folders without decreasing performance.
  • You can only compress individual files by storing them in a compressed folder. If you move or extract the files into an uncompressed folder, they will be uncompressed.

Using NTFS Compressed Files and Folders

NTFS compressed files can be read and written to by any Windows-based or MS-DOS-based application without first being uncompressed by another program. When an application, such as Microsoft Word 2000, or an operating system command, such as Copy, requests access to a compressed file, NTFS automatically uncompresses the file before making it available. When you close or explicitly save a file, NTFS compresses it again.

NTFS allocates disk space based on uncompressed file size. If you copy a compressed file to an NTFS volume with enough space for the compressed file, but not enough space for the uncompressed file, you might get an error message stating that there is not enough disk space for the file, and the file will not be copied to the volume.

Compressing Files and Folders Using NTFS Compression

You can set the compression state of folders and files and you can change the color that is used to display compressed files and folders in Microsoft Windows Explorer.

If you want to set the compression state of a folder or file, right-click the folder or file in Windows Explorer, click Properties, and then click Advanced. In the Advanced Attributes dialog box, shown in Figure 14.2, select the Compress Contents To Save Disk Space check box. Click OK, and then, in the Properties dialog box, click Apply.

NTFS encryption and compression are mutually exclusive. For that reason, if you select the Encrypt Contents To Secure Data check box, you cannot compress the folder or file.
Figure 14.2??The Advanced Attributes dialog box
To change the compression state for a file or folder, you must have Write permission for that file or folder.

The compression state for a folder does not reflect the compression state of the files and subfolders in that folder. A folder can be compressed, yet all of the files in that folder can be uncompressed. Alternatively, an uncompressed folder can contain compressed files. When you compress a folder that contains one or more files, folders, or both, Windows XP Professional displays the Confirm Attribute Changes dialog box, shown in Figure 14.3.

Figure 14.3??The Confirm Attribute Changes dialog box

The Confirm Attribute Changes dialog box has the two additional options explained in Table 14.1.

Table 14.1??Confirm Attribute Changes Dialog Box Options

Compressing a Drive or Volume Using NTFS Compression

You can set the compression state of an entire NTFS drive or volume. To do so, in Windows Explorer, right-click the drive or volume, and then click Properties. In the Properties dialog box, select the Compress Drive To Save Disk Space check box, as shown in Figure 14.4, and then click OK.

Figure 14.4??The Local Disk (C:) Properties dialog box

Displaying NTFS Compressed Files and Folders in a Different Color

Windows Explorer makes it easy for you to quickly determine if a file or folder is compressed. By default, it displays the names of compressed files and folders in a different color to distinguish them from those that are uncompressed.

You can control the display of compressed files and folders in a different color by doing the following:

  1. In Windows Explorer, on the Tools menu, click Folder Options.
  2. In the View tab, clear the Show Encrypted Or Compressed Files In Color check box to turn off the displaying of the names of compressed files and folders in a different color or select it to display the names in a different color.

Copying and Moving NTFS Compressed Files and Folders

There are rules that determine whether the compression state of files and folders is retained when you copy or move them within and between NTFS and FAT volumes. The following list describes how Windows XP Professional treats the compression state of a file or folder when you copy or move a compressed file or folder within or between NTFS volumes or between NTFS and FAT volumes.

  • Copying a file within an NTFS volume.??When you copy a file within an NTFS volume (shown as A in Figure 14.5), the file inherits the compression state of the target folder. For example, if you copy a compressed file to an uncompressed folder, the file is automatically uncompressed.
  • Moving a file or folder within an NTFS volume.??When you move a file or folder within an NTFS volume (shown as B in Figure 14.5), the file or folder retains its original compression state. For example, if you move a compressed file to an uncompressed folder, the file remains compressed.
  • Copying a file or folder between NTFS volumes.??When you copy a file or folder between NTFS volumes (shown as C in Figure 14.5), the file or folder inherits the compression state of the target folder.
  • Moving a file or folder between NTFS volumes.??When you move a file or folder between NTFS volumes (shown as C in Figure 14.5), the file or folder inherits the compression state of the target folder. Because Windows XP Professional treats a move as a copy and a delete, the files inherit the compression state of the target folder.
  • Moving or copying a file or folder to a FAT volume.??Windows XP Professional supports compression only for NTFS files, so when you move or copy a compressed NTFS file or folder to a FAT volume, Windows XP Professional automatically uncompresses the file or folder.
  • Moving or copying a compressed file or folder to a floppy disk.??When you move or copy a compressed NTFS file or folder to a floppy disk, Windows XP Professional automatically uncompresses the file or folder.
Figure 14.5??The effects of copying and moving compressed folders and files
When you copy a compressed NTFS file, Windows XP Professional uncompresses the file, copies the file, and then compresses the file again as a new file. This might cause performance degradation.

Using NTFS Compression Guidelines

The following list provides best practices for using compression on NTFS volumes:

  • Because some file types compress more than others, select file types to compress based on the anticipated resulting file size. For example, because Windows bitmap files contain more redundant data than application executable files, this file type compresses to a smaller size. Bitmaps often compress to less than 50 percent of the original file size, whereas application files rarely compress to less than 75 percent of the original size.
  • Do not store compressed files, such as PKZIP files, in a compressed folder. Windows XP Professional will attempt to compress the file, wasting system time and yielding no additional disk space.
  • Compress static data rather than data that changes frequently. Compressing and uncompressing files incurs some system overhead. By choosing to compress files that are infrequently accessed, you minimize the amount of system time dedicated to compression and uncompression activities.
  • NTFS compression can cause performance degradation when you copy and move files. When a compressed file is copied, it is uncompressed, copied, and then compressed again as a new file. Compress data that is not copied or moved frequently.

Practice:?Managing Compression

In this practice, you use NTFS compression to compress files and folders. You uncompress a file and test the effects that copying and moving files have on compression. In the last portion of the practice, you create a compressed folder using the Compressed Folders feature.

In this practice, it is assumed that you installed Windows XP Professional on the C drive and that the C drive is formatted with NTFS. If you installed Windows XP Professional on a different partition and that partition is formatted with NTFS, use that drive letter when the practice refers to drive C.

Run the Compression file in the Demos folder on the CD-ROM accompanying this book for a demonstration of creating a compressed folder using the Compressed Folders feature and using NTFS compression to compress files and folders, and testing the effects that copying and moving files have on compression.

Exercise 1: Compressing Files in an NTFS Partition

In this exercise, you use Windows Explorer to compress files and folders to make more disk space available on your NTFS partition. You also configure Windows Explorer to display the compressed files and folders in a different color. Next, you uncompress a file. Finally, you view the effects that copying and moving files have on compressed files.

To view the capacity and free space for drive C

  1. Log on as Fred or with an account that is a member of the Administrators group.
  2. Click Start, right-click My Computer, and then click Explore.
  3. Right-click drive C, and then click Properties.

    Windows XP Professional displays the Local Disk (C:) Properties dialog box with the General tab active.

    What is the capacity of drive C?

    What is the free space on drive C?

  4. Click Cancel to close the Local Disk (C:) Properties dialog box and return to Windows Explorer.

To create an NTFS compressed folder

  1. In Windows Explorer, expand Local Disk (C:).
  2. Create a folder on drive C and name it Compressed.
    To create a folder on drive C, click Local Disk (C:). On the File menu, click New. Windows XP Professional creates a folder named New Folder in the root folder of the C drive. Right-click New Folder and then click Rename. Type Compressed and then press Enter.
  3. Click Compressed to select it.
  4. Create a folder in Compressed and name it Compressed2.
  5. Right-click the Compressed folder, and then click Properties.

    Windows XP Professional displays the Compressed Properties dialog box with the General tab active.

  6. In the General tab, click Advanced.

    Windows XP Professional displays the Advanced Attributes dialog box.

  7. Select the Compress Contents To Save Disk Space check box.
  8. Select the Encrypt Contents To Secure Data check box.

    Notice that the system automatically removes the check from the Compress Contents To Save Disk Space check box.

  9. Select the Compress Contents To Save Disk Space check box.
  10. Click OK to return to the Compressed Properties dialog box.
  11. Click Apply to apply your settings.

    Windows XP Professional displays the Confirm Attribute Changes dialog box, prompting you to specify whether to compress only this folder or this folder and all subfolders.

  12. Select the Apply Changes To This Folder, Subfolders And Files check box, and then click OK.

    Windows XP Professional displays the Applying Attributes message box, indicating the progress of the operation and the paths and names of folders and files as they are compressed. Because there is little data on drive C, compression completes too quickly for you to view this dialog box.

  13. Click OK to close the Properties dialog box.

To uncompress a folder

  1. In Windows Explorer, expand the Compressed folder.
  2. In the Compressed folder, right-click Compressed2, and then click Properties.

    Windows XP Professional displays the Compressed2 Properties dialog box with the General tab active.

  3. In the General tab, click Advanced.

    Windows XP Professional displays the Advanced Attributes dialog box.

  4. Clear the Compress Contents To Save Disk Space check box, and then click OK to apply your settings and return to the Compressed2 Properties dialog box.
  5. Click OK to close the Compressed2 Properties dialog box.

    Because the Compressed2 folder is empty, Windows XP Professional does not display the Confirm Attributes Changes dialog box asking you to specify whether to uncompress only this folder or this folder and all subfolders.

    What indication do you have that the Compressed2 folder is no longer compressed?

Exercise 2: Copying and Moving Files

In this exercise, you see the effects that copying and moving files has on compressed files.

To create a compressed file

  1. In Windows Explorer, click the Compressed folder.
  2. On the File menu, click New, and then click Text Document.
  3. Type Text1 and then press Enter.

    How can you verify that Text1 is compressed?

To copy a compressed file to an uncompressed folder

  1. Copy (hold down Ctrl and drag the file) Text1 to the Compressed\Compressed2 folder.
  2. Examine the properties for Text1 in the Compressed2 folder.

    Is the Text1 file in the Compressed\Compressed2 folder compressed or uncompressed? Why?

To move a compressed file to an uncompressed folder

  1. Examine the properties of the Text1 file in the Compressed folder.

    Is Text1 compressed or uncompressed?

  2. Move Text1 to the Compressed\Compressed2 folder. If the Confirm File Replace dialog box appears, asking whether you want to replace the file, click Yes.
  3. Examine the properties of Text1 in the Compressed2 folder.

    Is Text1 compressed or uncompressed? Why?

To uncompress the NTFS Compressed folder

  1. In Windows Explorer, right-click the Compressed folder, and then click Properties.

    Windows XP Professional displays the Compressed Properties dialog box with the General tab active.

  2. In the General tab, click Advanced.

    Windows XP Professional displays the Advanced Attributes dialog box.

  3. Clear the Compress Contents To Save Disk Space check box, and then click OK to return to the Compressed Properties dialog box.
  4. Click Apply.

    Windows XP Professional displays the Confirm Attributes Changes dialog box, prompting you to specify whether to uncompress only this folder or this folder and all subfolders.

  5. Click Apply Changes To This Folder, Subfolders And All Files, and then click OK.

    Windows XP Professional briefly displays the Applying Attributes message box. This might happen so fast that you do not see it.

  6. Click OK to close the Properties dialog box, and then close Windows Explorer.

Exercise 3: Creating Compressed Folders

In this exercise, you will create a compressed folder using the Compressed Folders feature.

To create a compressed folder using the Compressed Folders feature

  1. Start Windows Explorer.
  2. Click File and then click New.

    Compressed Folder is an option on the New menu.

  3. Click Compressed Folder.

    You have just created a compressed folder. Notice the zipper icon that identifies compressed folders. You can drag and drop files into the compressed folder and they will automatically be compressed. If you copy a file from the compressed folder to another that is not compressed, the file will no longer be compressed.

  4. Close Windows Explorer.

Lesson Review

The following questions will help you determine whether you have learned enough to move on to the next lesson. If you have difficulty answering these questions, review the material in this lesson before beginning the next lesson. The answers are in Appendix A, "Questions and Answers."

  1. When Bob tried to copy a compressed file from one NTFS volume to another, the file was not copied and he got an error message stating that there was not enough disk space for the file. Before he attempted to copy the file, Bob verified that there was enough room for the compressed bitmap on the destination volume. Why did he get the error message?
  2. Which of the following will Windows XP Professional allow you to compress using NTFS compression? (Choose all answers that are correct.)
    1. A FAT volume
    2. An NTFS volume
    3. A bitmap stored on a floppy
    4. A folder on an NTFS volume
  3. When you move a file between NTFS volumes, does the file retain the compression state of the source folder or does the file inherit the compression state of the target folder? Why?
  4. What does Windows XP Professional do when you try to copy a compressed file to a floppy disk? Why?
  5. Which of the following types of files or data are good candidates for NTFS compression? (Choose all statements that are correct.)
    1. Encrypted data
    2. Frequently updated data
    3. Bitmaps
    4. Static data

Lesson Summary

  • In Windows XP Professional, NTFS compression allows you to compress files, folders, or an entire volume.
  • Any Windows-based or MS-DOS-based application can read and write to compressed files without having the files uncompressed by another program.
  • Use the View tab in the Folder Options dialog box in Windows Explorer to display NTFS compressed files and folders in a different color to distinguish them from uncompressed files and folders.
  • NTFS encryption and compression are mutually exclusive.
  • When you copy a file within an NTFS volume, the file inherits the compression state of the target folder.
  • When you move a file or folder within an NTFS volume, the file or folder retains its original compression state.
  • When you copy a file or folder between NTFS volumes, the file or folder inherits the compression state of the target folder.
  • When you move or copy a compressed NTFS file or folder to a floppy disk or to a FAT volume, Windows XP Professional automatically uncompresses the file or folder.
  • To create a compressed folder using the Compressed Folders feature, start Windows Explorer, click File, click New, and then click Compressed Folder.
  • A compressed folder created by the Compressed Folders feature appears in Windows Explorer as an icon of a zipper across a folder.
  • You can drag and drop files into a compressed folder created using the Compressed Folders feature and the files are automatically compressed.