Im new to Mac and to Applescript but i have a long history with other programming languages. What i need to do is convert the paths passed to my droplet to valid Unix style paths so i can pass them as options to the shell!
The problem being that i cant find any referance to any string handeling functions/commands that Applescript may have other than things like &. Heres what i need to do:
cut the HD name from the path
convert “:” to “/”
Unless of course theirs a better way to pass Mac style paths to the shell?
Greetings, and welcome to using a mac and applescript.
To go from colon->slash, use 'POSIX path of". To go from slash->colon, use ‘POSIX file’
set theHD to (path to startup disk as string) --> "Macintosh HD:"
set posixHD to (POSIX path of theHD) --> "/"
set theDesktop to (path to desktop) --> "Macintosh HD:Users:jobu:Desktop:"
set posixDesktop to (POSIX path of theDesktop) --> "/Users/jobu/Desktop/"
set posixFile to POSIX file (posixDesktop) as string --> Back to: "Macintosh HD:Users:jobu:Desktop:"
Thanks guys! Just what i was looking for! One last problem though: once i have the output from this shell - how can i display it in a basic GUI, the standard display dialog cuts my output after the size of the box has been reached so what im looking for is something like a text box with a scrole bar. Any ideas?
I really don’t have an answer to your question. I believe that applescript studio (Xcode) has this ability but I have never used it.
An ugly hack that I have used in the past is to redirect the shell output to a text file and then have textedit or bbedit or some such text program open the file. (I said it was ugly!) It is such an inelegant solution that I am ashamed to even mention it.