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.

I want to achieve the same output in Powershell as I would get by running dir [pattern] /s /b in cmd.exe.

Recursive directory search, with a filter, printing out just the full file paths of found files.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

dir -Filter *.txt -Recurse | Select Fullname

(Dir being a PowerShell alias for Get-ChildItem).

Fullname includes the Path (like /B), if you just want the file names, use Select Name.

share|improve this answer
Get-ChildItem . -recurse | Select-Object Name

the . means "this folder" a .. would mean the parent folder of this folder. This is an example of the output that I get:

Name
----
0409
1033
AdvancedInstallers
appmgmt
ar-SA
BestPractices
bg-BG
Boot
catroot
catroot2
CodeIntegrity
com
config
cs
cs-CZ
da-DK
de

to include a pattern use -filter or -include. Personally I use -include because it seems more intuitive to me. It also allows multiple patterns:

Get-ChildItem . -recurse -include *.exe, *.dll | Select-Object Name
share|improve this answer

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.