Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 search for files in the Windows command line, using wildcards like this?

share|improve this question
For what are you trying to use the wildcard search? A command line program, .bat file? For a .bat file scenario, just use nested batch for loops. for /d %%D in (C:\Users\*) do for %%F in (%%~fD\AppData\Local\*.txt) do echo %%~fF As for command line programs, the wildchar handling is up to the authors of that specific program. – David Ruhmann Dec 26 '12 at 17:11
I am trying to search in some path with wildcards in the path, not only in the file name, I need some way using existing windows tools (cmd.exe), or powershell, or some external free tool! – Mohamed Sakher Sawan Dec 26 '12 at 17:18
up vote 4 down vote accepted

Windows PowerShell can do this easily.

Get-ChildItem C:\Users\*\AppData\Local\*.txt

If you want to include subfolders:

Get-ChildItem C:\Users\*\AppData\Local\*.txt -recurse

Regarding Hidden (etc.) files, Powershell's help Get-ChildItem says:

By default, Get-ChildItem gets non-hidden items, but you can use the Directory, File, Hidden, ReadOnly, and System parameters to get only items with these attributes. To create a complex attribute search, use the Attributes parameter. If you use these parameters, Get-ChildItem gets only the items that meet all search conditions, as though the parameters were connected by an AND operator.

share|improve this answer
How to include hidden and system dirs and files? – Mohamed Sakher Sawan Dec 26 '12 at 17:39
@MohamedSakherSawan check out the edit I added. – Ƭᴇcʜιᴇ007 Dec 26 '12 at 18:01

Any good Unix shell for Windows will do this.

For example, here's a screenshot of my Hamilton C shell doing your example (sorry, no matches) and a couple others that do produce matches. The ... wildcard used in the third example matches zero or more directory levels, whatever it takes for the rest of the pattern to match.

Wildcarding using Hamilton C shell on Windows 7 x64

And here's how you might do it with Cygwin bash. A few differences here because Cygwin follows Unix conventions: Paths are usually typed with forward slashes and the backslash is the escape character. Since Unix doesn't understand drive letters, they've introduced a /cydrive/c notation to refer to the C: drive. As on Unix, wildcarding is case-sensitive. And while it supports the usual multiple directory level wildcarding you'd like, it doesn't include the ... I added to my shell. (Instead, you'd probably use find.)

Wildcarding using Cygwin bash on Windows 7 x64

share|improve this answer

Your Answer


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.