Technology in terms you understand. Sign up for my weekly newsletter, "Confident Computing", for more solutions you can use to make your life easier. Click here.

Tip of the Day: Searching Via the Command Prompt

Command Line Search

Windows search function has improved dramatically, but in the long run, I still occasionally find using the Command Prompt as, if not more, effective.

Fire up a Command Prompt (you may want to “Run as administrator” to be able to search everywhere). In that Command Prompt, type the following (each followed by the Enter key):

CD \

By default, the Command Prompt opens with C:\Windows\System32 as the “current” directory or folder. “CD” is the Change Directory command, and “\” indicates the top of the folder tree. This changes the current folder to the top of the C: drive, allowing us to search the entire thing.

DIR /s/p *.pdf

DIR is the “DIRectory” command, which lists the contents of that directory (aka folder). “/s” means list everything in the current directory and all sub-directories. “/p” means paginate – stop after each screen of results, so you have a chance to read it. “*.pdf” is what we’re searching for – in this case, any document that ends in “.pdf”, meaning all pdf documents.

The result will be a list of all pdf documents on your C: drive.

Change “*.pdf” to whatever you’re looking for. The results, as they say, may surprise you.

Related Video

2 comments on “Tip of the Day: Searching Via the Command Prompt”

  1. This tip can be expanded upon. 🙂

    If you don’t like the dreariness of paging through a list of files one screenful at a time for half an hour (or longer!), omit the “/p” switch and append the following to your “dir” command, after a space (without the quotes): “> C:\List.TXT”, so that the whole thing reads:

    “dir /s *.pdf > C:\List.TXT”

    Now all the results of your “dir” search command will be written to a file, “List.TXT”, in the root “C:\” directory.

    (And before anyone asks, yes, you CAN [and SHOULD!] change the location and/or name of the destination file; I only give “C:\List.TXT” here as an example.)

    I’ll sometimes make use of this technique so that I can employ my favorite text editor’s search commands on the resulting list of files; my text editor’s “search” functionality tends to be rather more robust, and to have more available options, than either a CMD prompt, or Windows itself, can provide.

    And furthermore, provided you’ve prepared by numbering the MP3 filenames, you can use this exact same technique within a temporary directory where you’ve gathered songs to burn to CD, to provide a “Quck-&-Dirty” track listing for the CD cover!

    Reply
    • That’s a great tip. I used that to create a DJ song list for all of my .mp3s. I then opened it with MS Word and edited and formatted it

      Reply

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.