Friday, May 22, 2009

Search for files quickly with dir and findstr

This is a great way to search for files on your computer. Many people use Windows search or even download Google Search to their PC, but this method allows you to have an updated indexed list of all your current files.

c:\> dir c:\ /b /s > c:\dirlist.txt


After you run the above command, your computer will index all current files and list them in the dirlist.txt file located in the C:\ root.

After this, you can run a series of commands to pull/pipe information out of it.  For example, if you want to search for all .jgp files on your computer you can run the following command:

c:\> findstr /i /e .jpg c:\dirlist.txt


If you want to search for all .mpg files withing C:\Windows, you could run:

c:\> findstr /i /b c:\windows\ c:\dirlist.txt | findstr /i /e .mpg

I really like this method because once you run the dir, you can run searches on it and get results back quicker than other conventional methods.

Source:  Alex @Net

No comments: