Thursday 25 August 2011

Simple Command Line File Search with Windows XP and 7

Microsoft Logo

Ever want to do a really simple file search in Windows? Do you find the Windows graphical search tools difficult to use and unreliable?



Well fear not. You can use the Windows command line and the dir command to do most file searches.



To open a command prompt window:

On Windows XP: Start --> Programs --> Accessories --> Command Prompt

On Windows 7: Start --> All Programs --> Accessories --> Command Prompt



Now you can use the cd command to move around your disk.

To move up 1 directory level: cd ..

To move to the directory root: cd \ or in most cases cd c:\

To move into a directory (to the windows dir from the root directory for example): cd windows



Once you are in the desired directory you are ready to search. Here is a basic example of the command:

dir /s /b myfile.txt



This example would search the current directory and all sub directories for the myfile.txt file. The /s option searches subdirectories. The /b option displays the path to the file so you can see the path to the file and use a tool like File Manager to navigate to it.



Here are a couple more examples.



Here is an example of a search for all files that end in .help.txt. The * means all files with this file extension. This search takes place in the c:\windows directory.



C:\WINDOWS>dir /s /b *.help.txt

C:\WINDOWS\system32\WindowsPowerShell\v1.0\about_aliases.help.txt

C:\WINDOWS\system32\WindowsPowerShell\v1.0\about_arithmetic_operators.help.txt

C:\WINDOWS\system32\WindowsPowerShell\v1.0\about_arrays.help.txt





Here is an example of a search for all files that contain winhelp in the file name with any extension.



C:\WINDOWS>dir /s /b winhelp.*

C:\WINDOWS\winhelp.exe

C:\WINDOWS\system32\winhelp.hlp

C:\WINDOWS\system32\dllcache\winhelp.exe



C:\WINDOWS>





As long as you do not search the entire disk, performance is really quite snappy. Even searching the entire disk is still pretty good.

No comments:

Post a Comment