Convert POSIX path to alias

Hi

Sorry bit of a basic question. How do I convert a POSIX path to an alias path?

I have tried this


set POSIX_path to "/AE_Work/Smurfit_Kappa_Chelmsford/"

set newPath to my convertPathToAlias(POSIX_path)

on convertPathToAlias(POSIX_path)
	tell application "System Events"
		try
			return (path of disk item (POSIX_path as string)) as alias
		on error
			return (path of disk item (path of POSIX_path) as string) as alias
		end try
	end tell
end convertPathToAlias

but I get an error saying – Can’t get path of “/AE_Work/Smurfit_Kappa_Chelmsford/”

“AE_Work” is a mounted disk on my desktop and the folder “Smurfit_Kappa_Chelmsford” does exist within.

Any help would be great.

Thanks

No need to involve System Events:

set POSIX_path to "/AE_Work/Smurfit_Kappa_Chelmsford/"
return POSIX file POSIX_path as alias

Thanks for your suggestion

Still no luck I’m afraid.

I tried your code . Now I get error

Can’t make file “Macintosh HD:AE_Work:Smurfit_Kappa_Chelmsford:” into type alias.

I would expect the alias to look like “AE_Work:Smurfit_Kappa_Chelmsford:” (without the “Macintosh HD:”)

Not sure though if that is why it is erroring.

Thanks

Yes. Sorry. It’s a mounted disk, so its POSIX path begins with /Volumes/.

When HFS it begins with Macintosh HD, or whatever the name of the boot disk.

Edit: I just tried with a disk’s POSIX path, and it returns the disk name without boot disk name.
Please post the actual code that errors.

Perfect!

Yes…“/Volumes/AE_Work/Smurfit_Kappa_Chelmsford/” works fine.

Thanks a lot.

Oh, good.

Let’s not talk at the same time… :confused:

Oh sorry.

I was keen to get this bit figured out because was a silly stumbling block that was stopping me progressing further.

Thanks again