Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I list all files containing the term "foobar" in a given directory under Windows XP?

share|improve this question

migrated from Dec 9 '09 at 11:47

This question came from our site for system and network administrators.


dir *foobar*

Add the "/a" argument if you want to see files with the "hidden" or "system" attributes set.


Initially, I assumed you mean filenames. It occurs to me that you might mean files that contain the text "foobar" in their data stream. That's a bit more difficult w/ built-in tools. You can try the FIND command, but it doesn't support Unicode:

@echo off
for /f "usebackq" %%i in (`dir /a-dsh /b`) do (
 for /f "usebackq tokens=3" %%d in (`find /c /i "foobar" %%i`) do if %%d NEQ 0 echo %%i

That script will return the names of files that have "foobar" (case insensitive-- remove the "/i" from the find command-line for case-sensitive matching) in them.

I exclude "Hidden" and "System" files from the search because FIND will return "File not found" on them unless you remove the "Hidden" or "System" attribute before running FIND on them. Distinctly un-handy...

share|improve this answer
is it possible to open a cmd prompt at a current folder when viewing the folder in windows explorer? – user3183 Dec 9 '09 at 1:28
You're looking for "Open Command Window Here", from: – Evan Anderson Dec 9 '09 at 1:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .