0

I use this code to convert all mp4 files in a folder to mkv

for %f IN (*.mp4) DO ffmpeg -i "%f" -c copy -strict -2 "%~nf.mkv" 

However I'm looking for a way to convert .mp4 as well as .ts (telesync) files to mkv in one go. Right now I have to do it separately. Any help would be appreciated.

Thanks.

1
  • 4
    for %f IN (*.mp4 *.ts) DO ... Commented Aug 11, 2020 at 9:51

2 Answers 2

3

The help (for /?) isn't very clear about the syntax. It simply states:

file-set is a one or more file names. 

SS64 is a bit more explicit, but also completely holds back about the possibility of using wildcards:

Filenameset A set of one or more files, enclosed in parentheses (file1,file2) 

Actually, for accepts several file masks (like dir):

for %f IN (*.mp4 *.ts "I also want this file.wmv") DO ... 

To correctly process file names/masks with spaces or other special characters, quote them.
(whether you separate them with a space or a comma is up to you)

Sign up to request clarification or add additional context in comments.

Comments

0

I have started using .mkv for all recorded tv especially, mpeg and avc held in a .ts format. I use mkvtoolnix tools now to do the conversion.

I tend to do video work on windows as it is my main gaming pc which has the big graphics card but i'm not a massive fan of windows powershell, so I tend to use cygwin on top of windows, then automate the converstion process with a bash script, here is shell script I use to look for all .ts files in a directory and convert them to .mkv format. if you wanted to do other formats, either change "-name *.ts" to something like "-name *.mp4" of just remove the section altogether for everything.

#!/bin/bash # Set the cygwin file path to the mkv tool "mkvmerge.exe" this is a linux style file path. MkvMergeBin=/drives/f/VideoWork/MkvToolsInstall/mkvtoolnix/mkvmerge.exe # Set the directory where you store all the video files you want to convert, as this is running in cygwin it is a windows style file path. InputDir='F:\VideoWork' # Set the directory where you want to output the converted files. Again a windows style file path. OutputDir='F:\VideoWork' # The find command will look only in the given InputDir location and in this example look only for all files ending .ts. the output of this command is piped to the while iteration and each file is passed to mkvmerge for conversion and output to the given output dir. find "$InputDir" -type f -name '*.ts' -maxdepth 1 -exec basename {} ';' | { while read InFile ; do $MkvMergeBin -o "${OutputDir}\\${InFile%.ts}.mkv" "${InputDir}\\${InFile}" done } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.