Getting file version

Hey fellow scripters!
This is basic stuff, I know, but I couldn’t find anything about it on this site or elsewhere on the net.

Why does this work:


set theFile to choose file
set fileVersion to short version of (info for theFile)
display alert fileVersion

…but not this:


set fileVersion to short version of (info for (((path to applications folder) & "Application.app")) as unicode text)
display alert fileVersion

I just get “File Macintosh HD (10.5):Applications:Application.app wasn’t found”, even when it’s ABSOLUTELY there.

Is it a variable type error?
Setting it as an alias doesn’t seem to work, nor does setting it as file (…)

Any help appreciated!

Hi,

info for expects a file specifier or an alias,
Try this, path to has a direct parameter to coerce the alias to text:


set fileVersion to short version of (info for file ((path to applications folder as text) & "Application.app"))
display alert fileVersion

But this is actually too complicated, there’s an easier way

set fileVersion to version of application "Application" as text
display alert fileVersion

Thanks a million!

Does this work in earlier versions of applescript as well? Ideally, I’d like it to work on 10.3 systems.

Best,
O

Yes, it does

Yes, but in Mac OS 10.4 it LAUNCHES the stupid application in order to get its version :(.

this syntax doesn’t launch the application


set fileVersion to short version of (info for file ((path to applications folder as text) & "iTunes.app"))
display alert fileVersion