How can I list all files containing the term "foobar" in a given directory under Windows XP?
1 Answer
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...
-
is it possible to open a cmd prompt at a current folder when viewing the folder in windows explorer?– user3183Dec 9, 2009 at 1:28
-
You're looking for "Open Command Window Here", from: microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx Dec 9, 2009 at 1:34