powershell - How can I output Handbrake output to both the screen and to a file? -


so i've been using handbrake command line encode video collection store on nas can use on htpc. looking way output both screen can watch it's output it's encoding, file can go , @ particular encoding session.

my solution use 1 powershell window run encoding , output file, powershell window read log file , display on screen. works, want improve it, it's not perfect. because read file script reads @ set interval, misses lines. if reduce interval, has effect on system performance, making encoding run bit slower. there way can redirect output of first window both file , screen?

the first powershell script (the 1 starts encoding) called "convert1.ps1" (run handbrake install directory):

net time \\odin |find "current time" ./handbrakecli.exe -i "<input file>" -o "<output file>" <handbrake parameters> 

the second powershell script output file, called "start_convert.ps1":

d:\conversions\convert.ps1 2>&1 | out-file d:\conversions\completed\movies\9.29.2010.log 

the third powershell script read log file, called "watch_output.ps1":

while (1) { (get-content d:\conversions\completed\movies\9.29.2010.log)[-1] start-sleep 5 } 

i'd like, ideally, down 1 powershell window running single script start encoding, output file, , display on screen.

edit (adding solution): 2 different ways it, i'm going latter since simpler.

way #1 - start-job resulting script start conversions:

start-job -name videoconvert -scriptblock { d:\conversions\convert.ps1 2>&1 | out-file d:\conversions\movies\movie.log } get-filetail -wait encoding unicode -path d:\conversions\completed\movies\movie.log 

way #2 - tee-object resulting script start conversions:

d:\conversions\convert.ps1 2>&1 |tee-object -file d:\conversions\completed\movies\movie.log 

thanks again all. works wanted work.

i use tee-object this:

./handbrakecli.exe -i infile -o outfile ... 2>&1 | tee-object -file movie.log 

added in 2>&1 capture errors log screen.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -