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.

There is no “InfoDictionary version” key – that’s the English-like name sometimes given for CFBundleInfoDictionaryVersion:

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:

set appVersion to version of application "App Store"

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

Shane;
I read over the preceding posts and think that my situation is a slight bit different, because I need the changes to persist. I think your ‘set appVersion to version of application “App Store”’ reads the Launch Services database. That is likely only refreshed on startup and any changes would not likely be written back on shutdown (speculation; not knowing much about these services).

My app currently does not have a defined CFBundleTypeExtensions item in an apps Info.plist.

If I’m trying to read/write the value(s) for the CFBundleTypeExtensions item in an apps Info.plist in order to retrieve/save the extension on which my app is to act. This is so that, if a default metadata filetype is not defined, the user can define one for the app to use.

  1. Is this wise to do.
  2. What is the best way to go about achieving this goal (maybe it’s not the via the plist?)

Shane;

Just found a thread, in which you were involved, that basically stated that writing to the Info.plist file of an app is potentially dangerous. (https://macscripter.net/viewtopic.php?id=43193&p=1)

I suspected this, which is why I asked about the “correct” way to store a user default. If you have any advice or perhaps an URL for an example, I’d be very interested. In the meantime, I’ll go over your book again and see if I missed something on this.

I found the answer to what I wanted to do.

See: https://forum.latenightsw.com/t/storing-persistent-values-in-preferences/864/6

It took me a while to find this post, but it looks like it should do what I am trying to do.