Searching for a file in Windows Explorer takes forever, but there’s a faster way if you’re willing to use the command prompt.
The amazing Twitter account SwiftOnSecurity posted this gem yesterday:
Stupid dirty cheap way to search an entire Windows drive for wildcard text in a file name, that I use all the time. 50x faster than trying to use Explorer.
1.) dir “search term*” /s
means start from root and /s means subdirectories
Example shows all .log files:
dir *.log /s
— SwiftOnSecurity (@SwiftOnSecurity) April 30, 2018
You can use this trick to search any drive and will usually finish in a few seconds. In the screenshot above, for example, I searched my drive for all files that include “justinpot” in the name by running
dir *justinpot* /s. Swift, in the tweet, searched for all log files on a drive by running
dir *.log /s.
Confused? Let’s break this down:
diris a command used to show files in the current directory, but which can also show files anywhere in the system.
- The backslash tells
dirto search from the root directory of the current drive.
dirto search all subdirectories.
*is used by command line apps as a wildcard. So
*.txtwill show you all files that end with “.txt”, while
project*will show you all filenames that begin with the word “project”
Put it all together and you’ve got a quick way to search any drive pretty quickly. Give it a try, but note that this won’t work in PowerShell.