Any PowerShell gurus around? I just can't figure out how to pipe command line program output to another command line program... What would be the powershell way to achieve this: Code: ffmpeg.exe -i "input.flac" -f wav {more args...} - | lame.exe {args go here} - "output.mp3" I.e. FFmpeg reads file and send the output directly to Lame through pipeline.
Is that even possible? I mean in linux the binary output of ffmpeg would have to go to std out which wouldn't normally make sense ( off the top of my head I can't think of any Linux commands that would send binary to std out unless its a user running e.g. cat on a binary file )
Code: ffmpeg.exe -i "input.flac" -f wav {more args...} - | foreach { lame.exe $_ - "output.mp3" } Am I correct assuming that ffmpeg.exe outputs one string which one you should pass to the lame.exe ? Common syntax for cases when first program outputs one single string: Code: $var = some1.exe some2.exe -arg $var # or some1.exe | foreach { some2.exe -arg $_ } In cases when first program outputs more than one string syntax is: Code: some1.exe | foreach { some2.exe -arg $_ } $_ - stands for current value passed through pipeline.
It doesn't seem to work. I think the PS escapes the data the first program is churning out or something. Oh well... It may not be possible to do this with PS. Also running command line applications in PS is a small pain in the arse. This works well but piping data is not possible as far as I know: Code: start -FilePath $pathtoapp -Args $appargs -NoNewWindow -Wait Code: $app = "S:\something\something.exe" #Works: &($app) -i something.txt -o something2.txt #Doesn't work because it thinks that there's one arg ("-i something.txt -o something2.txt") $args = "-i something.txt -o something2.txt" &($app) $args
Describe here what task you are seeking. I tried the following: Code: $qq = C:\Tools\SysinternalsSuite\autorunsc.exe $qq Code: $qq = C:\Tools\SysinternalsSuite\autorunsc.exe -b $qq Code: $qq = &("C:\Tools\SysinternalsSuite\autorunsc.exe") -b $qq Code: $aa = "-b" $qq = &("C:\Tools\SysinternalsSuite\autorunsc.exe") $aa $qq And PS prints me all strings that program did output and which PS did save into variable. You can`t use name "args" for variable because it has predefined meaning: $args - input arguments for a script, function, script block. When you assign any value to $args PS doesn`t show error - it just silently ignores the assignment.