Convert POSIX path to AppleScript path

I’m in a situation where I have this for example, from a text field in the UI:
/Users/joe/Desktop

And I’d like to covert any given path like that to a colon-delimited path like this:
Macintosh HD:Users:joe:Desktop

So I can interact with the finder to create a folder.
I’ve been using something like this:


tell application "Finder"
					set macPath to POSIX file theDirectory -- where theDirectory is the /Users/joe/Desktop string from a text field in the UI
					make new folder in folder macPath with properties {name:theFolder} -- where theFolder is a string from a text field in the UI
end tell

But I keep getting this error:
Finder got an error: Can’t get «class psxf» “/Users/joe/Desktop”. (-1728)

In a nutshell what I’m trying to do is, take the unix style path from the UI, and a name from the UI, and make a folder at the unix style path location, named whatever the name is from the string in the UI.

What am i doing wrong? Anyone that can chime in, I’d be very grateful!

Maybe this will work:

set macPath to POSIX file theDirectory as Unicode text -- where theDirectory is the /Users/joe/Desktop string from a text field in the UI 

tell application "Finder"
	make new folder in folder macPath with properties {name:theFolder} -- where theFolder is a string from a text field in the UI 
end tell

– Rob

That worked! Thanks Rob! :lol:

Although your problem has been solved, here are some coercions which may be useful in future scripting (Note: Finder not required):

set theFile to "/Users/myName/a.scpt"
return {POSIX file theFile, (POSIX file theFile) as alias, (POSIX file theFile) as string}
-- Returns: {file "MyDisk:Users:myName:a.scpt", alias "MyDisk:Users:myName:a.scpt", "MyDisk:Users:myName:a.scpt"}

-- This code will ensure a path of unknown type is converted to alias format:
if the class of theFile is not alias then set theFile to (POSIX file theFile) as alias