Automate bash script for right-click option

In Windows I right-click on an MKV file (or multiple MKV files) and choose Other Options > Send to > Remux.bat and it very quickly creates MP4 files in that same location with the same names.


My question: Is there a way to do this in macOS Ventura by creating a bash file, making it executable and renaming it with .command suffix then right-clicking on an MKV file and pointing to/executing the bash file?


This is the Windows batch file:

@echo off
if [%1]==[] goto :eof
:loop
C:\ffmpeg\bin\ffmpeg -i %1 -c copy -copyts %1.mp4
shift
if not [%1]==[] goto loop

I've run this command from Terminal successfully:

ffmpeg -i example.mkv -c copy example.mp4


I don't know much at all about programming but was reading about bash files. I will need help with the creation of a macOS "batch" file with right-click options if possible.

MacBook Pro 15″, macOS 13.1

Posted on Jan 20, 2023 8:44 AM

Reply
5 replies

Jan 20, 2023 9:34 AM in response to mac4554

You are not in Kansas anymore… and macOS shares no code or batch file portability with Windoze.


You would have less grief by just using the free visual Handbrake application that can readily convert MKV to MP4. I have it installed on my M1 mini running Ventura 13.1.


By default, there is no means to double-click a Bash (or Zsh) shell script saved with the .command extension and have it input an arbitrary MKV video. Apple does not install ffmpeg and you are on your own to find a precompiled ffmpeg compatible with Ventura. I say precompiled because if you use a package manager to install ffmpeg, the dependencies that must also be installed to complete the build goes on for days.


If you succeed in that effort, it must be installed somewhere that is discoverable in your SHELL PATH statement. A good choice is /usr/local/bin or $HOME/bin.


You either create an AppleScript function that launches a file chooser from the script so you can select the MKV file and then pass that path into the script, or you do the more accepted approach and create an Automator or Apple Shortcuts solution as a Quick Action where you select the MKV first and then upon right-clicking on that MKV in the Finder, you select the Quick Actions menu and the actual Quick Action that performs the conversion to MP4.



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automate bash script for right-click option

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.