Mac-path to Unix-path (string operations)

Hi guys,

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:

  1. cut the HD name from the path
  2. convert “:” to “/”

Unless of course theirs a better way to pass Mac style paths to the shell?

Thanks in advance for any help of advice guys,

Mark.

netytan

If you have a file reference, you can create a unix style path like so:

set the_file to choose file
set the_path to POSIX path of the_file

If there are spaces in the file name, or you need a name in quotes for another reason, use the syntax:

set the_file to choose file
set the_path to quoted form of POSIX path of the_file

Andy

Greetings, and welcome to using a mac and applescript. :slight_smile:

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:"

j

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?

Thanks again!

Mark.

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.

Andy