Open a file that I double-click with app created with Script Editor
I created an Application from Script Editor with this content:
do shell script "PATH=/Library/TeX/texbin:$PATH ¬
open -n /Applications/Xournal++.app"
and I called it /Users/enzotib/Applications/Xournal-mod.app
.
It works if I double click the application, then select a file .xopp
to open.
The question is: how should I modify the script, so that I can associate the file extension open the file that I double-click with the application?.xopp
with the application
Edit
I changed the title, that was "Associate file type with app created from Script Editor", because I realised it was misleading.
Going off the answer you provided:
on open fileName
do shell script "PATH=/Library/TeX/texbin:$PATH ¬
open -n -a /Applications/Xournal++.app " & ¬
quoted form of POSIX path of fileName
end open
a simpler solution would have been:
on open {fileName}
tell application "Xournal++" to open (fileName as «class furl»)
end open
which will work for even non-scriptable applications that accept high level Apple events. For those that don't, then:
on open {fileName}
tell application id "com.apple.Finder" to open fileName ¬
using application file "/Applications/Xournal++.app"
end open
However, overall, it's curious where you're going through the effort of passing it a file to open, only to have it open the file in some other application. This is a bit like mounting a mirror on the wall to look at your monitor while using the computer, unless this is actually just a small extract from a larger script.