1
0 Comments

How do I modify my FFmpeg script in a batch file so that the output file Video.Mkv is directed to a folder named “FIXED” located in the same directory as the script?

Mk Fixed
for /R %%f IN (*.mkv) do ffmpeg -i "%%f" -map 0:m:language=English? -c copy "%%~nf.MKV"

At present, the script searches the main folder and its subfolders for Mkv files and retains only the English audio track. However, it saves all the Mkv files in the same directory as the script instead of the designated “Fixed” folder.

Although I have another script that meets my requirements, I was unable to make it work for recursively scanning subfolders during batch scanning. This alternative script directs the output to the appropriate folder.

Mk Fixed
for %%a in ("*mkv*") do ffmpeg -i "%%a" -map 0:0 -c:v copy -map 0:3 -c:a copy "Fixed\%%~na".mkv

When I attempt to include “fixed%%~nf.Mkv” in my initial script, I encounter a problem.

[matroska,webm @ 0000018fb8518840] File ended prematurely

It would be excellent if the script could retain the directory structure from the source to the destination folder in the output.

— Response: I have made changes to my script to accommodate this.

mkdir Fixed
for /R %%f IN (*.mkv) do ffmpeg -i "%%f" -map 0:m:language=English? -c copy "Fixed\%%~nf.mkv"

Although it is functional, the output still does not preserve the structure of subfolders. I want FFMpeg to scan through the subdirectories and convert the video files while preserving the folder structure.

I should have provided more information earlier. My operating system is Windows 10 Pro, and the directory structure is as follows: C:\Users\User\Desktop\Convert (contains the files that need to be converted), the folder where FFMPEG and the script.bat file are located, as well as subfolders containing files that require conversion.

Example C:\Users\User\Desktop\Convert\Tv Show\Show 1\Season 1\Show.mkv
Goal C:\Users\User\Desktop\Convert\Fixed\Tv Show\Show 1\Season 1\Show.mkv 
Askify Moderator Edited question April 29, 2023