Taking command of the Context Menu in macOS
The blog post outlines methods for processing video and audio files on macOS using command line tools and applications like ContextMenu and Automator, including ffmpeg for re-encoding media files.
Read original articleThe blog post discusses methods for processing video and audio files on macOS using command line tools and applications like ContextMenu and Automator. It highlights a tool created by Morten Just that wraps ffmpeg for re-encoding media files to smaller sizes. The author shares a simple one-line command for converting files using ffmpeg, assuming it is installed via Homebrew. For multiple files, a loop can be used to process them sequentially or in parallel. The post also details how to set up an Automator Quick Action to convert files, although it notes limitations regarding file type specificity.
ContextMenu, a paid app, is presented as a more flexible alternative to Automator, allowing users to create custom actions for various file types and providing options for output visibility and confirmation before execution. The author mentions using the gifsicle command line tool for optimizing GIFs and provides examples of commands for both compression and scaling. Additionally, a repository of shared ContextMenu actions is available, offering various useful commands for file manipulation. The post concludes with an invitation for support and engagement from readers.
- Many users prefer using Shortcuts or Automator for enhancing their productivity with context menu options.
- Several commenters share their custom workflows and scripts, highlighting the versatility of tools like Automator and GNU Parallel.
- There is a desire for better integration and functionality in macOS tools, with some users expressing frustration over limitations in Shortcuts compared to Automator.
- Users discuss the importance of context menu quick actions and their impact on workflow efficiency.
- Some comments touch on the differences in user experience between macOS and other operating systems like Linux, emphasizing a need for better documentation and openness in macOS.
I even built my own Mac app which sits in my menubar syncing tags on project folders with the status of projects in a web app I built. Even better that is synced with iCloud so I can access all of those files and tags from my other devices.
I had not considered how else I could improve this situation with context menu options, but now I want to explore how I could use Automator to improve this setup even more.
> Apply to multiple types (files or directories; can be as granular as file extension)
> Show output (sometimes you want to see the results of the command)
> Confirmation before running (if it’s a potentially dangerous operation)
Nit: The last 2 points are actually possible in Automator
Some examples:
* Remove PDF password: https://www.sheshbabu.com/posts/remove-pdf-passwords-using-q...
* Summarize text with Ollama: https://www.sheshbabu.com/posts/system-wide-text-summarizati...
Workflow receives current "image files" in "any application"
Image = Action
Run shell script:
Shell: /bin/zsh
Pass input: As argument
for f in "$@"
do
/opt/homebrew/bin/exiftool -all= -tagsfromfile @ -ColorSpaceTags -Orientation $f
done
----Will be under the Quick Actions menu.
I tried the same with Shortcuts, but I cannot get it to run from the context menu, only within Shortcuts during testing. Maybe something limiting shell command access from Shortcuts? Not sure.
Very neat, I looked into it briefly and it looks like using {@%.*} is not posix compliant, but a bashism. However the substitution itself is posix compliant, so I may start using something like this in my scripts. Need to look at this more, but this is a heck of a lot less clunky than `echo | sed`... I need to go read `info coreutils` more closely.....
- Search Image (search selected image through google lens)
- Compress Images (compress selected images with jpegoptim or pngquant)
- Open In Terminal / Vim (open selected directory in terminal / selected files in Vim)
- Merge Subtitles (merge .srt subtitles into video files)
Also discovered it's very useful to enable the preview panel in Finder (View -> Show Preview or cmd+shift+p) because it has 3 slots for quick action, much faster than going to context menu.
Also for showing output, you can use
osascript -e "display notification \"Message Here!\" with title \"Title Here!\""
[0] https://github.com/slmjkdbtl/rc/tree/master/shortcuts (shame that the .shortcut files aren't text based like automator files, no easy way to preview)The ones on the blog post appear as services because the take text, but I have others that work on files as Quick Actions.
I wish Swift could replace AppleScript, but that is asking for too much. I dread the day AppleScript is not longer supported. Shortcuts is way too limited in my experience.