Find files fast
This article will help you search for files in seconds using locate-like commands in Windows.
The File is a major concept in all modern desktop systems. All your documents, music, videos are stored in files and if you frequently search for files, prefer command line interface and like clear and simple solutions, the following one may be interesting for you.
If you have tried some application to search the files, you may have noticed that they can be divided into two big classes depending on whether they use cache or not. For example, Google Desktop indexes all the documents and stores them in cache; this is why it returns search results so fast. Others, like Total Commander, search directly over files on hard disk - this is slower but the results are always up-to-date.
The fast search requires caching. And the simplest cache of the file names can be created with the dir command. Just open the command prompt and type:
dir c:\ /b /s /on > c:\dirlist.txt
This command goes through all the folders (/s key) on disk c:\ in alphabetical order (/on key) and saves folders and files with full paths (/b key) into the c:\dirlist.txt file (> c:\dirlist.txt construction). This command may take several minutes to complete, depending on the number of files on your disk.
You may update the dirlist anytime you want and even schedule this command using Task Scheduler.
You can search for files using the findstr command as follows:
findstr asdf c:\dirlist.txt
Output:
c:\WITSuite\Data\MySQL-5.0\test\1234asdf.frm c:\WITSuite\Data\MySQL-5.0\test\1234asdf.MYD c:\WITSuite\Data\MySQL-5.0\test\1234asdf.MYI c:\WITSuite\Data\MySQL-5.0\test\asdf.frm c:\WITSuite\Data\MySQL-5.0\test\asdf.MYD c:\WITSuite\Data\MySQL-5.0\test\asdf.MYI c:\WITSuite\Data\MySQL-5.0\test\asdfasdf.frm c:\WITSuite\Data\MySQL-5.0\test\asdfasdf.MYD c:\WITSuite\Data\MySQL-5.0\test\asdfasdf.MYI
findstr has a lot of options including search by regular expression, show negative matches, and so on. Combining it with dir output or with the dirlist cache you can do very intelligent searches.
Search for all .bak and .tmp files:
findstr /r "\.tmp$ \.bak$" c:\dirlist.txt
Search for all .avi files in the C:\Multimedia\ folder:
dir /b /s c:\multimedia\ | findstr /r "\.avi$"


