2

I'd like to have different apps handle .jpg files based on a naming convention I'll use for the .jpg files. Specifically most will go to Xee, but ones containing thumb should instead cause VLC to be called with the same path and file name, but with .mp4 (or .mkv, etc.) extension.

Is there an existing script / app that does this? I'm guessing the way to do it would be to create a shim app (sort of like choosy) that handles the main file type based on extension, and then hands off to the apps you configure based on a ruleset.

2 Answers 2

2

Just create an Applescript Droplet to read the name and extension of dropped files and triage them with if statements. This script should get you started. Save it as an application, and then you can put it in your dock or some place convenient to drop files on it.

on open these_items
    repeat with i from 1 to the count of these_items
        set this_item to item i of these_items
        set the item_info to info for this_item without size
        set theName to name of item_info
        try
            set theExtension to the name extension of item_info
        on error
            set theExtension to ""
        end try

        if theName contains "thumb" then
            tell application "VLC"
                activate
                open this_item
            end tell
        else if theExtension contains "jpeg" then
            tell application "Preview"
                activate
                open this_item
            end tell
        else
            -- open with system default app
            tell application "Finder" to open this_item
        end if
    end repeat
end open
-5

If you want to be able to double-click a file and launch different app based on file pattern, you could use LinCastor Browser for that. It is user friendly alternative to writing AppleScript conditions by hand.

  1. You make the LinCastor default app for extensions you want to handle differently
  2. Create "single browser" for each pattern you want to handle
  3. Configure condition for each pattern (e.g. URL path contains "thumb") and associate it with the right app.

Hint: click "+" button while holding option/cmd key in order to create more complex conditions (e.g. using AND / OR / NOT etc.)

You can also configure a "menu", which let you choose what app to open.

DISCLAIMER: I'm involved in LinCastor's development

2
  • 3
    Welcome to Ask Different. This doesn’t explain how to make the same changes as the AppleScript that shows how to send jpeg to preview and other file to VLC. Making sure you directly answer the question with details here will increase the chance for bores up and reduce the flags for spam.
    – bmike
    Apr 26, 2019 at 23:58
  • Hi. If you are a developer or might have a conflict of interest, just be sure to add that as a footnote, disclaimer. It’s ok to self promote when the answers are fair, address the issue and consider other options as well. Then people feel there is a balanced and honest answer and the promotion is a side effect of having a helpful answer.
    – bmike
    Apr 28, 2019 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .