0

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

0

1 Answer 1

2

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...

2

You must log in to answer this question.

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