Saturday, December 16, 2017

#1 2017-12-06 05:07:33 pm

rkubasiak
Member
Registered: 2010-08-03
Posts: 25

Read PLIST file, error when key name has a space

Can someone help this code snippet?

tell application "System Events"
    tell property list file "/Applications/App Store.app/Contents/Info.plist"
        tell contents
            set appVersion to value of property list item "InfoDictionary version"
        end tell
    end tell
end tell


If I change the item I'm trying to read to one with no space in its name, it will run fine.

Offline

 

#2 2017-12-06 06:03:29 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Read PLIST file, error when key name has a space

There is no "InfoDictionary version" key -- that's the English-like name sometimes given for CFBundleInfoDictionaryVersion:

Applescript:

tell application "System Events"
   tell property list file "/Applications/App Store.app/Contents/Info.plist"
       tell contents
           set appVersion to value of property list item "CFBundleInfoDictionaryVersion"
       end tell
   end tell
end tell

But that's not the application version, and will probably return "6.0" for every app. If you want the application version, just ask for it:

Applescript:

set appVersion to version of application "App Store"


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2017-12-11 05:25:33 pm

rkubasiak
Member
Registered: 2010-08-03
Posts: 25

Re: Read PLIST file, error when key name has a space

Thanks Shane.  I felt like a dope not realizing I was looking at the pretty print names of keys.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)