alias to path reference

I can’t remember how to get a path reference (file reference) from an alias reference. Do I need to reread to AS Language Guide?

Yes :wink:

assuming path reference represents the literal path string

aliasReference as text --> HFS path e.g "Macintosh HD:Applications:iTunes.app"
POSIX path of aliasReference --> POSIX path e.g "/Applications/iTunes.app"

I think it’s a glitch or change in AppleScirpt. You can’t get a file specification anymore. I jumped from Jaguar to mountain lion, so trying to learn the changes.

Thanks anyway,

from 10.2. to 10.8 is indeed a real huge jump

the file specification specifier is outdated at least since AppleScript 2 (10.5)

HI Stefank,

What I meant was that I couldn’t get something like this:

file “HD:somefile”

from an alias reference.

Thanks,

Yes you can


file (aliasReference as text)

OK, I saw your post after I posted. Need to do a lot of testing.

Thanks a lot,

Hi StefanK,

file SomePathString is not working.

set f to choose file as string
file f

does not work. If I do it in the Finder then, I get a Finder reference.

sorry, in this case you have to write


set f to (choose file) as string
a reference to file f


Hi StefanK,

Your last script ended with the file reference wrapped in the script object:

file “HD:Users:myhome:Desktop:data.rtf” of «script»

I ended up using posix path and posix file:


set fp to (choose file) as string
set pp to POSIX path of fp
set fs to POSIX file pp

result – file “HD:Users:myhome:Desktop:data.rtf”

Thanks a lot.

Model: MacBook Pro
AppleScript: 2.2.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)

An easier and faster solution is:
 

-- coerce the AppleScript Alias to old File Specification

(choose file) as «class furl»

 

1 Like