Apple Pfad zur Anwendung mit variablen
-
06-07-2019 - |
Frage
Wenn ich ein Applescript-Schnipsel wie diese
tell application "Finder"
set thePath to (POSIX path of (path to application "MyApp"))
end tell
es wird zu mir zurück
"/ Applications / MyApp.app"
Nun, was kann ich nicht scheinen, um herauszufinden, wie stattdessen angeben „MyApp“ über eine Variable und nicht die wörtlichen.
.Meine Apple in einigen XML-Werte liest, von denen der Name der Anwendung, wobei ich in interessant bin Ich habe dies versucht:
tell application "Finder"
set thePath to (POSIX path of (path to application someVariable))
end tell
aber einfach sagt mir den Fehler
"Finder bekam eine Fehlermeldung: Kann nicht machen Anwendung. "" In den Typ Konstante" MyApp
Alle Ideen, wie kann ich das tun?
Lösung
Die Antwort (oder zumindest eine Antwort) ist:
set theApp to "MyApp"
set pathToTarget to POSIX path of (path to application theApp)
Da Pfad zur Anwendung ist ein Teil der Standard-Additions wird der Finder nicht benötigt wird.
Dank Stephan K auf MacScripter für mich gerade auf dieser Einstellung.