Save mkvmerge output in log file

Hi

I would like to know if there is a way to save mkvmerge output (=what appear on the windows terminal) in a .txt file.

Aternatively in do like this in 2 steps:
command>txt.txt
type “txt.txt”

But i don’t really like it because i would like to compile on the window terminal and save at the same time. I know some soft cli offer this possibility

Welcome!

If you use a Unix-like shell such as bash or zsh you can use the tee command:

mkvmerge <arguments> | tee output.txt

On Windows there’s a built-in equivalent in the PowerShell called Tee-Object. You call it like this:

mkvmerge <arguments> | Tee-Object -FilePath output.txt

Hello,

Thanks for your answer. I have maybe a dumb but i have that error message when i tried

when i use this the windows terminal just crash

mkvmerge <arguments> | Tee-Object -FilePath output.txt

So i have tried this

mkvmerge <arguments> ^| Tee-Object -FilePath output.txt

And i have this error message
mkvmerge v78.0 (‘Running’) 64-bit
Erreur : Le fichier « | » ne peut pas être ouvert en lecture : open file error.

maybe there is something i do wrongly, i hope you can help me again

thanks in advance

I have no idea why your console crashed; sorry.

Using the syntax … ^| … is definitely wrong. The ^ resets the special meaning of the pipe operator | and passes a verbatim | character to mkvmerge as a command line parameter along with all the following words. mkvmerge then thinks | is a file name & doesn’t find a file with that name.

Put differently, what I wrote mkvmerge <arguments> | Tee-Object -FilePath output.txt is interpreted by PowerShell as:

Start two programs. The first one is mkvmerge with command line arguments <arguments>. The second one is Tee-Object (a PowerShell scriptlet) with command line arguments -FilePath output.txt. Take the output of the first program and hand it over to the second program.

Whereas what you wrote, mkvmerge <arguments> ^| Tee-Object -FilePath output.txt, is interpreted as:

Start only one program, mkvmerge, with command line arguments <arguments> | Tee-Object -FilePath output.txt. Take its output & print it on the console.

thanks for your answer.

I have performed more test and i have realized it is not the | which creates the crash but i don’t use correctly the Tee-Object

so let’s write a complet command line and maybe you could tell me what is wrong
I will take the most simple command with mkvmerge for the example

“C:\Program Files\MKVToolNix\mkvmerge.exe” -o “D:\output.mkv” “D:\input.mkv” | Tee-Object -FilePath “D:\output.txt`”

“C:\Program Files\MKVToolNix\mkvmerge.exe” -o “D:\output.mkv” “D:\input.mkv” | Tee-Object -"D:" output.txt

i have tried those 2 commands and it doesn’t work, the console crash

but if i try
echo 1 | echo 2
the console display 2 without crashing

thanks in advance for your help

Sorry, but I really cannot help you with the console crashing. The first command you’ve shown looks good to me; it works on my end with slightly altered paths:

Z:\home\mosu\prog\video\mingw\links\cross-x86_64-w64-mingw32\mkvmerge.exe -o d:\mkv\out.mkv D:\mkv\v.avi  | Tee-Object -FilePath D:\mkv\out.txt

Remember: you must run this in PowerShell, not in plain old cmd.exe.

oh that is the thing, i tried it in cmd.exe.
How do i run in powershell ?

i have create a .bat with thousands of lines and the mkvmerge command is one of them. can i safely run a .bat through powershell or will it make a lot of unexpected problem ?
If that is not possible i will forget this idea to get the output both on console and .txt because my .txt is a hundreads of hours already

Sorry, but I’m not doing general Windows support here. Google for how to use the PowerShell, learn about PowerShell scripts (those with .ps1 as the extension). Or look into finding a Windows port of the Unix tool tee if you want to continue using cmd.exe; it does pretty much similar things as the PowerShell-built-in function Tee-Object.

No problem, you already help me a lot.

Thanks for everything your are doing.