Search code examples
applescript

AppleScript to open a URL from Calendar using Google Chrome depending on the first part of it


I want to make an AppleScript to, if the first part of the link is ____ it will open it in Chrome.

open http://stackoverflow.com -a "Google Chrome"

I got that, but how would I do it depending on the first part of the link.

For example, if the first part of it is https://meet.google.com/xxx-xxxx-xxx to open in Google Chrome.

The xxxxx changes every time.

Alternative solutions welcomed too.


Solution

  • Here is an alternative solution, tested under macOS High Sierra 10.13.6 and it worked:

    • Automator > New > Service
      • With settings: Service receives selected text in Calendar
    • Add a Run Shell Script action, with settings:
      • Shell: /bin/bash
      • Pass input: as arguments
      • Replace the default code with: open "$1" -a "Google Chrome"
    • Save it as: Open URL in Google Chrome

    Then in Calendar, right click on the URL and select Open URL in Google Chrome from the Services context menu.

    It's not a single click scenario, but gets the job done.