I created a macos application launcher who is launching a apple script as the exec file. The problem is that I can not intercept the file of the open command in the script or do not know or find somewhere on the net. The Launcher self does work ok. To demonstrate I set it on my github :
when I run it out off terminal with open command for example: test.txt is just a simple text file.
open -a "CvrAppBash.app" "test.txt" --args "--some-arg-1" "--some-arg-2"
I can have all info needed in the launched apple script to work further with it. also the args. But how to get the file name here "test.txt" in the script ?
At this time my display dialog out gives:
The Macos Hfs path is:
'MACOSHSIERRA:Applications:MacPorts:CvrAppBash.app:'
The Posix path is:
'/Applications/MacPorts/CvrAppBash.app'
The Application name is:
'CvrAppBash'
The args are:
'--some-arg-1' '--some-arg-2'
What I wan't also to have is the filename here "test.txt" to work further with.
I did not had a lot of response. Now found a solution to the problem. Once You now it is very simple. It is only that you needed two sections in the apple script file. One section on run --- end run. Another on open -- end open. The applescript needs to be saved out of applescript editor using convert save as application. What also should work but does not is using osacompile -o Newapplication.app thescript.apple. At least it does not work on macos High Sierra 10.13.6. when using osacompile. Below the way how to do it in applescript.
To look more examples on how to use this way of application launcher see the mentions code examples below. I set them my github. Quit possible that depending on You're macos version You need to rebuild the application by just saving the script in site as application with apple script editor.
I set the application bunch self on my git hub :
The TestLaunchCvr.app on my git hub
I Added an example of practical use of this script to my git repo Gedit3 launcher
You can see the plain apple script code on : Gedit 3 launcher script
The macports installed gedit can now be used with commands :
or
By clicking on the application self out of finder.
or
By selecting files in finder and then select Gedit3 out of applications list.