Recipe 8.9. Searching for Files or Folders


Problem

You want to find the files or folders that match certain criteria.

Solution

Using a graphical user interface

  1. Select Search from the Start menu and click All files and folders if you are presented with an option for the types of files to search.

  2. Now you'll be able to search for a particular file or folder name (use * as the wildcard) or enter one or more words to search within text-based files.

  3. Select the drive, drives or folder you want to search in.

  4. Click the Search button.

  5. Below the search button you can select additional advanced search options, which allows you to search based on file timestamp, file size, and various file attributes.

Using a command-line interface

The where.exe utility searches the files in your path that match a pattern. This command finds all files that begin with net and have a .exe extension:

> where net*.exe

You can also use where to find files in a specific folder or tree of folders. This command finds all .vbs scripts whose names contain the letters foo:

> where /r c:\scripts *foo*.vbs

Windows comes with two other tools you can use to search for files that contain a certain string: find.exe and findstr.exe. The latter is more robust. If you only need to find the files in the current directory that contain the letters log, you can use this command:

> findstr log *

This next command performs a case-insensitive search (/i) for all nonbinary files (/p) on the d: drive (/s) that contain the text "confidential" (/c):

> findstr /s /p /i /c:"confidential" d:\*

findstr includes some regular expression support. For a list of all the features, look at the command help information (findstr /?).

Using downloadable software

With the introduction of Google Desktop search (http://desktop.google.com) in 2004, providing robust search capability for local files became a hot topic. Before long, both Yahoo (http://desktop.yahoo.com) and Microsoft (http://beta.toolbar.msn.com) released similar tools. All are free and provide roughly the same features. Take a look at each tool's web site for more information about the types of files that are indexed and can be searched.

If you want to search for strings within binary files, take a look at the Sysinternals strings.exe command. The following command displays any text strings contained in binary files within the Program Files directory:

> strings -s "c:\program files"

See Also

MS KB 185476, "HOWTO: Search Directories to Find or List Files," and "Inside Secrets of MSN Desktop Search" at http://www.windowsdevcenter.com/pub/a/windows/2004/12/21/msd_desktop_search.html



Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net