This portable snippet of shell code will process files in the current working directory (but not in subdirectories):
for f in ./*.mkv; do [ -f "${f%.mkv}.mp4" ] && echo rm "$f"done
Just in case, the above is a dry run, it only prints what it would do. If this looks fine, remove exactly the string echo
to "arm" the snippet, then run the altered version.
Note the standard is ./*.mkv
does not match dotfiles. In Bash, if you want our snippet to match also dotfiles, invoke shopt -s dotglob
beforehand. For completeness: shopt -u dotglob
sets the standard behavior.