Working with the Filesystem, Drives, Data, and Search

If you're looking for a guide to the Windows Vista filesystem, you've come to the right place. This article, the first of three parts, is excerpted from chapter four of the book Windows Vista in a Nutshell, written by Preston Gralla (O'Reilly, 2006; ISBN: 0596527071). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
July 12, 2007
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

At the heart of Windows Vista are the filesystem and the files in it; without files, there's no reason to use a computer, after all. When Windows Vista was first announced, Microsoft had big plans for a completely redone filesystem, along with powerful search tools, all built on top of a new filesystem database.

Reality intruded, and those plans had to be curtailed. Still, despite that, the ways to navigate your hard disk and find files have been dramatically upgraded compared to previous versions of Windows. Windows Explorer has gotten a facelift, along with new capabilities for filtering and viewing files. And the new Search is one of Windows Vista's best new features. Not only is it available almost everywhere, but it's also lightning fast and includes considerable new ways to search, including the ability to save searches for future use. This chapter covers that, along with all other aspects of the filesystem, Windows Explorer, and Search.

Here is an alphabetical reference of entries in this chapter:

Explorer

Folder and Search Options

OpenFiles

File Compare (comp)

Folder Properties

Search

File Compare (fc)

Indexing Options

Shadow Copies

File Expansion Utility

Label Subst
File Properties

NTFS Compression Utility

Windows Explorer

Explorer

See "Windows Explorer, "later in this chapter.

File Compare (comp)
\windows\system32\comp.exe

Compare the contents of two files (or sets of files) byte by byte and display the differences between them.

To open

Command Prompt -> comp

Usage

  comp [file1] [file2] [/n=number] [/c] [/offline] [/d] [/a] [/l]

Description

File Compare (comp.exe) compares two files (or more, using wildcards) and reports whether the files are identical. If the files are identical, comp.exe will report Files compare OK. If the files are the same size but have different contents, comp.exe displays the differences, character by character, by reporting Compare Error at OFFSET n  (where n  is the byte offset, or the location of the difference, in characters, from the beginning of the file). If the files are different sizes, comp.exe reports Files are different sizes, and the comparison stops there.

Here are the options for comp.exe:

file1, file2
   Specify the filenames of the files to compare. For any
   files that aren't in the current directory, you'll need to
   include the full path. If file1  includes a wildcard, all
   matching files are compared to file2 . Likewise, if  
 file2
 
includes a wildcard, each matching file is 
   compared to file1 . If one or both of these
   parameters are omitted, comp.exe will prompt you for
   the files to be compared.

/n=number
  
Include the /n option to compare only the first
   specified number of lines in the files, or omit it to 
   compare the files in their entirety. For example,
   specify /n=5 to check on the first five lines in each 
   file.

/c
   Disregard the case of ASCII characters; upper-and
   lowercase letters are treated as identical.

/offline
   comp.exe normally skips files marked as "offline."
   Specify /offline (or just /off) to include offline files
   as well. (See "Sync Center," in Chapter 7, for more
   information on offline files.)

/d
   Display differences in decimal format.

/a
   Display differences in ASCII characters. The /a option
   is the default, so specifying it has no effect.

/l
   Include line numbers in any output.

Notes

  • Windows Vista actually comes with two file comparison utilities: comp.exe (this one) and fc.exe (discussed in the next section). comp.exe performs a character-by-character comparison, but displays differences only if the files are exactly the same size. fc.exe performs a line-by-line comparison and works regardless of the file sizes. For most users, fc.exe will be the tool of choice, as it displays the differences between the files and doesn't have any prompts, so you can use it from a WSH script or batch file.
  • You can also use File Compare in interactive mode, without first typing filenames. Type comp at the command prompt, and you'll be asked for the names of files to compare, along with any options for comparing.
  • Regardless of the outcome of the comparison, comp.exe will ask whether you want to perform another comparison. Although there's no way to disable this prompt, you can use the following workaround to bypass it:

      echo n | comp file1 file2

File Compare (fc)

\windows\system32\fc.exe

Compare the contents of two files (or sets of files) line by line and display the differences between them.

To open

Command Prompt -> fc

Usage

  fc file1 file2 [/a] [/c] [/lbn] [/n] [/t] [/w] [/offline] [/nnn]
   [/l]
  fc /b filename1 filename2

Description

File Compare (fc.exe) compares the contents of two files (or more, using wildcards) and displays the differences (if any). If the files are identical, fc.exe will report FC: no differences encountered. If the files are different, fc.exe lists the differing lines. Here's an example of how to use fc.exe.

Start with an ordinary text file--say, Bill.txt. Open it in Notepad, change one line, and save it into a new filename--say, Marty.txt. Then open a Command Prompt window, make sure you're in the same directory as the two files, and type the following:

  fc bill.txt marty.txt

The output will look something like this:

  Comparing files Bill.txt and Marty.txt
  ***** Bill.txt
  Way down Louisiana close to New Orleans
  Way back up in the woods among the evergreens
  There stood a log cabin made of earth and wood
  ***** Marty.txt
  Way down Louisiana close to New Orleans
  Way back up in the woods among the antihistamines
  There stood a log cabin made of earth and wood
  *****

For each line or sequence of lines that differs in the two files, fc.exe prints out a pair of excerpts from each file. The first and last lines in each excerpt are what the two files have in common and are included for context. The lines in between (only a single line in this example) show the differences. The report will include one pair of excerpts for each difference found; if there are three nonconsecutive differing lines, there will be six excerpts. Here are the options for fc.exe:

file1, file2

Specify the filenames of the files to compare. For any files that aren't in the current directory, you'll need to include the full path. If file1  includes a wildcard, all matching files are compared to file2 . Likewise, if file2  includes a wildcard, each matching file is compared to file1 . Both parameters are required.

/a

Display only the first and last lines for each set of differences, as opposed to the default of every different line. This option is applicable only if a single sequence of differing lines (resulting in a single excerpt pair) is three lines or longer; otherwise, /a has no effect.

/c

Disregard the case of ASCII characters; upper-and lowercase letters are treated as identical.

/lbn

Specify the maximum consecutive mismatches; /lb17 will list only the first 17 differing lines. If omitted, the default is 100 maximum mismatches.

/n

Include line numbers in the report.

/t

Preserve any tabs in the files being compared. By default, tabs are treated as spaces, with one tab equal to eight spaces.

/w

Compress whitespace (tabs and spaces) to a single space for comparison. This is possibly useful when comparing .html files, as web browsers will eliminate redundant tabs in spaces as well.

/offline

fc.exe normally skips files marked as "offline." Specify /offline (or simply /off) to include offline files as well. (See "Sync Center," in Chapter 7, for more information on offline files.)

/nnn

Specify the number of consecutive lines that must match after a mismatch. For example, if you specify /4, a mismatched line followed by three matching lines, followed by one or more mismatched lines, is treated as though it were a single sequence of mismatched lines in the report.

/l

Treat the files as ASCII (plain text). Because /l is the default, it has no effect.

/u

Treat the files as Unicode text.

/b

Treat the files as binary and perform the comparison on a byte-by-byte basis (similar to comp.exe, the other file comparison utility). Differing bytes are displayed in parallel columns, instead of in the pairs of excerpts explained earlier. A binary comparison is typically appropriate only for files of the same sizes, but unlike comp.exe, the comparison will still be performed if they are different sizes. You can't use the /b option in conjunction with any of the other options.

Notes

  • Windows Vista actually comes with two file comparison utilities: comp.exe (discussed in the preceding section) and fc.exe (this one). comp.exe performs a character-by-character comparison, but displays differences only if the files are exactly the same size. fc.exe performs a line-by-line comparison and works regardless of the file sizes. For most users, fc.exe will be the tool of choice, as it displays the differences between the files and doesn't have any prompts, so you can use it from a WSH script or batch file.
  • fc.exe is most useful when comparing two different but similar text files. For example, you can compare two Registry patches (because .reg files are plain-text files) made at two different times to see what changes have been made. See Chapter 13 for more information on Registry patches.
  • Although fc.exe can compare two binary files, if you try to compare two word processor documents (.doc and .wpd files are binary files), the results won't be terribly helpful. Try converting the documents to an ASCII-based format, such as .rtf or .html, and then perform an ASCII comparison. Naturally, most modern word processors have their own document comparison tools, but they can often be limited; although word processors may miss subtle formatting changes, fc.exe will catch every single difference.
  • If you just want to see whether two files are different, you can redirect the differences to the nul: device and use the fact that fc.exe sets an ERRORLEVEL of 1 when the files differ:

      fc file1 file2 > nul:
    if ERRORLEVEL 1 (echo Different) ELSE (echo Same)


    This will also let you compare two binary files without your command prompt beeping at you while you press Ctrl-C in a desperate attempt to halt the stream of non-ASCII characters flooding your screen.

File Expansion Utility

\windows\system32\expand.exe

Extract one or more compressed files from a cabinet (.cab) file.

To open

Command Prompt -> expand

Usage

  expand -d source.cab [-f:files]
  expand [-r] source.cab [destination]
  expand source.cab -f:files destinatio
n

Description

A cabinet file is a compressed archive commonly used to package application installation files. You use the File Expansion Utility to extract files embedded in these cabinet files. The utility takes the following options:

source.cab

The name of the cabinet (.cab) file from which to extract the files.

destination

The name of the folder in which to place the extracted files, a new filename to use for the extracted files, or a combination of the two. If using the -f option, destination is mandatory and must include a filename (with or without wildcards).

-d

Display (list) the contents of the specified cabinet file.

-r

Specify -r (recursive) without destination to extract all the files contained in the specified cabinet file. For example:

  expand -r package.cab

Specify -r along with destination to rename the files according to the file specification included in destination . For example, the following extracts all the files in package.cab and renames their file extensions to .txt:

  expand -r package.cab *.txt

-f:files

Use the -f option to specify one or more files to extract; use this if you don't want to extract all the files from the cabinet file. For example, the following extracts the file uno.txt from package.cab:

  expand package.cab -f:uno.txt uno.txt

Note that the destination  parameter is mandatory when using the -f option and is used to specify the target filename. In this example, as well as most times this program will be used, files and destination  will be the same.

Notes

  • The easiest method for extracting files from cabinets is to simply double-click the .cab file in Explorer and then drag the desired file(s) out. You can also use it when installing or repairing Windows Vista when Explorer isn't available.

See also

"Cabinet (CAB) Maker," in Chapter 10

File Properties

View and change the properties of files.

To open

Right-click a file -> Properties

Click a file -> Organize -> Properties

Description

The File Properties window has four tabs:

General

This tab (Figure 4-1) displays basic information about the file, including its location, type, size, and size on disk; the date it was created, modified, and last accessed; and its attributes. You can change the program that opens it by clicking the Change button, and you can change the file attributes by selecting Read-only or Hidden. The Advanced button lets you compress and/or encrypt the file, add or take away the file from the index for searching, and add or take away the Archive bit (for use in backups).

Why are there two listings for file size--one for size, and one for size on disk? There are two cases where the file size and size on disk are different:

    • The cluster size of your NTFS filesystem dictates the size of the chunks that are set aside for files. On an NTFS filesystem with 4 KB clusters, a 1 KB file would use up 4 KB of disk space, and a 5 KB file would use up 8 KB.
    • If a file has been compressed, the size listing shows its uncompressed size, and the size on disk shows its actual size on your hard disk.


      Figure 4-1.  The General tab, which shows you basic information about the file

 

Security

This tab (Figure 4-2) shows you who has access to read and modify the file and its attributes, and lets you change those permissions. Click each group and username and you'll be shown the rights that person or group has to the file-- whether they can read the file, modify the file, and so on. You can modify the permissions for each person or group, add new groups or people and set their permissions, and delete people or groups, which means they would have no access to the file.

The various file permission options and their meanings are quite complex, and beyond the scope of this book. However, if you want more details about the available options, go to the Microsoft Knowledge Base article at http://support.microsoft.com/kb/308419/en-us.



Figure 4-2.  The Security tab, which lets you see what rights different people and groups have to the file--and lets you alter them

Details

This tab (Figure 4-3) displays the metatags associated with the file, as well as a wide variety of other information, including the basic file information shown in the General tab. It also has a great deal of program-specific information. For example, a Word document will display what template was used to create the file, the number of pages in the file, the word count, the character count, the line count, the paragraph count, the total length of time during which the file has been edited, and so on. You can also remove metatags and properties from the file by clicking the Remove Properties and Personal Information link. The details for each file type are quite different from one another. Graphics files, for example, include resolution, bit depth, width and height, and other similar information, as well as a quality rating that users can apply to the file.


Figure 4-3.  The Details tab, which displays metatags and other useful information about the file

 

Previous Versions

This tab (Figure 4-4) lets you view, save, or restore a previous version of a file, if such a version is available. Two types of previous versions may be available: those from a backup and those from what Windows Vista calls shadow copies.A shadow copy is a copy of a file made when Windows creates a restore point. (See "System Protection and System Restore," in Chapter 11, for details.) Different files and types of folders have differing options for how you handle previous versions, but in general, you'll be able to open and save the previous version of a file to a different location, or restore it over the existing files.


Figure 4-4.  The Previous Versions tab, which lets you restore previous versions of the file

Microsoft Office files may have another tab in addition to the standard four:

Custom

This tab (Figure 4-5) displays custom information about Microsoft Office files. You can add new values, and modify and delete existing values.

Notes

  1. To restore a previous version of a file without using the File Properties screen, right-click the file in Windows Explorer and select "Restore previous versions." You'll receive a warning before you overwrite the existing folder with the previous one.
  2. Some file types may have other tabs in addition to the ones mentioned here, depending on whether the program that created it created those additional tabs.
  3. Music files include a great deal of detailed information, including the artist, album, year of release, genre, bit rate, and so on.



    Figure 4-5.  The Custom tab, which is for Microsoft Office files

See also

"Folder Properties," discussed next, "System Protection and System Restore," in Chapter 11, and "Sharing Resources and Files," in Chapter 7

Please check back next week for the continuation of this article.

blog comments powered by Disqus
BRAINDUMP ARTICLES

- Microsoft Windows 8 Committed to Cloud Compu...
- Independent Developers Favor Windows Phone 7
- Dell Introduces VMware-based Cloud
- Microsoft and Skype Agree to Acquisition Deal
- Transfer Contacts in Microsoft Outlook
- Zune`s Next Steps
- Safari Books Online Review
- Does Microsoft Get Touch Screens Now?
- Microsoft`s Record Quarterly Earnings Not En...
- Basic Operations and Registers in Assembly
- Assembly Coding within Visual C/C++ IDE
- New Microsoft Office Coming with a Twist
- Microsoft`s FUSE Labs Unveils Spindex Social...
- HP Slate with Windows 7: Dead or Alive?
- Windows Phone 7 Mobile OS to Rival Android a...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials