Windows – Search for a file with wildcards in the path using Windows command line

command linepowershellsearchwildcardswindows

How can I search for files in the Windows command line, using wildcards like this?

C:\Users\*\AppData\Local\*.txt

Best Answer

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.

Related Question