Search code examples
command-linewindows-10piping

Windows cmd: Piping dir output into start


So suppose I know there's some file(s) (all with the same extension) in my directory which I want to run only I don't know their name.

I could execute the following to get all the relevant file names (.ext is just an arbitrary extension here)

dir /b /a-d *.ext

And then I could call

start

on all those files.

But I'd like to skip a step and simply pipe the output from dir into start.

I've tried

dir /b /a-d *.ext | start

but all that does is open an empty shell. Any suggestions?


Solution

  • For completeness, PowerShell:

    Get-ChildItem *.exe | ForEach-Object { Start-Process $_ }
    

    shorter (with aliases):

    gci *.exe | % { start $_ }