MACSCRPT Archives

January 2011

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Stan Cleveland <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 19 Jan 2011 14:27:12 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (21 lines)
On Jan 19, 2011, at 1:59 PM, Claudio Braga wrote:

> I need to convert a file path (in the hfs form) to a unix path to start some shell script operations, I thought that something like this: 
> 
> set path to "HD:users:claudio:docs to examine:"
> set path to (posix path of x) 
> 
> would create a real unix kind of path, but I think there is a problem: yes the semicolumn is translated into slash, but the spaces are not treated (i.e. no backslash)
> 
> is it a known behaviour ? Am I using the wrong command ? what is the right procedure to convert a path to a unix path usable in a do shell script line ?

Hi Claudio,

In addition to Mark's comments, here are a couple more. The word "path" is a keyword in AppleScript (from Standard Additions), so shouldn't be used as a variable name. Also, in your sample code you define the first "path" variable, but then reference it as "x". With these things fixed, and Mark's suggestions, you code would look like this:

	set x to "HD:users:claudio:docs to examine:"
	set myPath to quoted form of (posix path of x)

HTH,
Stan C.

ATOM RSS1 RSS2