July 30th, 2024

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 articleLink Icon
CuriosityFrustrationEnthusiasm
Taking command of the Context Menu in macOS

The 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.

AI: What people are saying
The comments reflect a variety of user experiences and suggestions regarding macOS tools for media processing and workflow improvement.
  • 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.
Link Icon 19 comments
By @nerdjon - 3 months
I have recently been looking at how I can use some Mac native tools to improve my workflow. Finally exploring tags and smart folders for example.

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.

By @ctippett - 3 months
BetterTouchTool also includes functionality to customise Finder's context-menu. I was hoping Hammerspoon would have something similar in their arsenal of APIs, but it doesn't look like they do.
By @rkwz - 3 months
> Submenu is optional

> 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...

By @nullindividual - 3 months
I've done this to strip Exif metadata from pictures using Automator. Uses homebrew and the exiftool package.

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.

By @jwells89 - 3 months
Semi-related, for devs who want to add Automator actions to their apps for users to make context menu items with, a while back I wrote a blog post and created a template that works with modern Xcode, since Xcode can no longer create them out of the box.

https://wells.dev/creating-an-automator-action-in-2023/

By @kelsey98765431 - 3 months
I enjoy some cool macos tricks, but the bash substitution was something I had never seen!

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.....

By @slmjkdbtl - 3 months
I've been using context menu quick action for a while [0] and they hugely improve my productivity. A few of my most used ones:

- 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)
By @rcarmo - 3 months
I just use Shortcuts: https://taoofmac.com/space/notes/2024/02/22/1900

The ones on the blog post appear as services because the take text, but I have others that work on files as Quick Actions.

By @hirvi74 - 3 months
The only use I ever get out Automator is basically just recording my actions, and then copying the actions into Script Editor in order to convert the actions to AppleScript.

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.

By @outworlder - 3 months
For parallel execution, instead of sending things to the background, we can use GNU Parallel – https://www.gnu.org/software/parallel/
By @sunny_sigara - 2 months
BetterTouchTool now can add Finder context menu (at root and submenu level + icons). Check this out https://maverickmac.github.io/2024-07-28/finder-context-menu...
By @iAkashPaul - 3 months
More than this pressing spacebar should have gotten some customisation by now, eg. certain mp4s/markdowns/any other file-extension for quick previews
By @MemphisTrain - 3 months
I do this on linux (dolphin) https://i.imgur.com/9C52czz.jpeg
By @MaxikCZ - 3 months
Is there a way to remove certain things from macos context menu? Ideally to just hide them unless I hold Shift or some other modifier?
By @serjester - 3 months
I use this to easily convert files and some basic data munging scripts - I’d be super curious what other people are doing.
By @a1o - 3 months
It’s weird how hacky macOS feels compared to Linux, where you can get a good idea on how things works due to openness and Windows, due to the good documentation Microsoft offers. In macOS it always feels like you have to be grateful about whatever is allowed and depend on mysterious closed source software.
By @mettamage - 3 months
I sometimes need a path name, so I have "Copy Path" in my context menu
By @jbverschoor - 3 months
Don’t invest in abandoned applications and frameworks