Question

This is my first time using applescript, I'm trying to open a file from a website in the default application for that file type and am not sure how to do it.

For example:

The file http://test.com/1234.docx should open in OpenOffice if they have that installed.

I can only get it to open in Safari, which I don't want because we use WebDav so the file is editable.

Is there any way to find the default text editor and open a url with that program?

Was it helpful?

Solution

You can use Finder's open command to open a file in the default application:

tell application "Finder"
    open POSIX file "/Library/Desktop Pictures/Abstract.jpg"
end tell

default application of (info for) gets the default application:

tell application "Finder"
    default application of (info for POSIX file "/Library/Desktop Pictures/Abstract.jpg")
end tell

You can use perl to get the default application for a URL scheme:

VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top