I wrote a shell script which calls an applescript to do some work. The applescript is in iCloud, so I'm manually writing the path to the document storage location...

 osascript ~/Library/Mobile\\ Documents/com~apple~ScriptEditor2/Documents/safari_get_tab_url.scpt

This is pretty ugly and looks fragile. I'm wonder if there is a cleaner way to get the path to this applescript file?

  • You can use quotes to cleanup the path for both bash and zsh shells. Depending on version, this will allow the ability to remove the \ before spaces in the path. – Jahhein Oct 13 '17 at 19:40

It's not really that fragile, providing the following is true:

  • The document will always be called the same and won't be renamed.
  • The Bundle ID (com~apple~ScriptEditor2) will not change thus changing the path to the file.
  • iCloud must remain enabled on the account.

Since it's only the first one you'd have to worry about, it seems perfectly fine to do just what you're saying, since a normal path would have the same problem anyway (normal = without any form of linking).


I'm not sure if I understand your question correctly, but how about this:

path to me                                                                      
return POSIX path of the result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.