Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

migrated from serverfault.com Dec 9 '09 at 11:47

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

1 Answer 1

Try:

dir *foobar*

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

Edit:

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: microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx –  Evan Anderson Dec 9 '09 at 1:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.