3

I am trying to create a batch file that will use mkvpropedit and remove all tags from all mkv files within a directory, I have so far managed to get this:

@ECHO OFF
TITLE MKV Metadata Remover
ECHO.
ECHO This program executes MKVPropedit to remove all metadata from all mkv 
files in the current directory.
ECHO.

:choice
set /P c=Are you sure you want to continue[Y/N]?
if /I "%c%" EQU "Y" goto :somewhere
if /I "%c%" EQU "N" goto :somewhere_else
goto :choice


:somewhere

FOR /F "tokens=*" %G IN ('dir /b *.mkv') DO mkvpropedit "%G" --tags all: -d 
title --delete-attachment "1" 
pause 
exit

:somewhere_else

ECHO Closing program...
pause
exit

However, when using the Y option the window just closes - even in a directory full of .mkv files.

Any help would be greatly appreciated, thanks for reading.

2 Answers 2

1

Try like this:

FOR %%G IN (*.mkv) DO mkvpropedit "%%G" --tags all: -d title --delete-attachment 1

Note: double % are needed for variables inside batch files (see: https://stackoverflow.com/questions/14509652/what-is-the-difference-between-and-in-a-cmd-file)

0

I used this from the Windows commandline with WSL bash: Windows/WSL/bash/

find . -name "*.mkv" -exec bash -c 'for f; do mkvpropedit --tags all: "${f%.*}.mkv" ; done' -- {} +

The first part, up to -exec, reads and stores a list of mp4 files. The -exec bash -c will execute a bash command line. From the "for f" to the next semicolon is a for loop that calls mkvpropedit to delete all tags in the mkv file in the current iteration of the loop. "done" ends the loop. The -- signals the end of options. "Within the inner command the {} represent the parameter expansion. In pain English, it means "insert the file name found here". "

Note mkvtoolnix must be installed: "apt install mkvtoolnix""."

Note this also works in the subdirectories.

2
  • What exactly is /bash*************************************? Mar 8, 2023 at 0:26
  • Welcome to SuperUser. Do you mind editing your answer and removing the asterisks. And you can improve your answer by explaining what each bit does and by citing a reference to those command options. Mar 8, 2023 at 1:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .