Help using shell to read and write plist not in the Prefs folder

Hi All,

I need a method to read and write a value to a plist file. These plist files store image information and there is one created for every capture. The path they exist at would be something like

The name of the property in the plist file is “Tagged” and it’s value is an integer with a value of 0 thru 9 or 50, 60 or 70.

It seems a shell command would do the trick but I’m not very familiar with shell. I was trying to start with just a read.


do shell script "defaults read /Users/marktorrance/Pictures/Capture%20One%20Default%20Session/Captures/Capture%20One%20Settings/ImageSettings/AF8T3331.TIF.plist Tagged"
return result

but I get

The contents of the plist file looks like

The application that creates the plist files for the images is called Capture One PRO
Thanks,
Mark

Hi Mark,

if there are spaces in the path, you must put the whole path into quotes
e.g. with the AppleScript command quoted form of.
And reading and writing with defaults you should omit the .plist extension.

try this:

set p to quoted form of POSIX path of ((path to pictures folder as Unicode text) & "Capture One Default Session:Captures:Capture One Settings:ImageSettings:AF8T3331.TIF")
do shell script "defaults read " & p & " Tagged"

Thanks Stefan,

I found another post of yours that helped.
http://bbs.applescript.net/viewtopic.php?id=20152
and the link to http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/defaults.1.html
was most helpful in pointing out

I have found that this


do shell script "defaults write ~/Desktop/0703-13_0068.TIF Tagged -int 0"

and this

do shell script "defaults read ~/Desktop/0703-13_0068.TIF Tagged"

work to read and write an integer to the property I need.
I tested with the file on the desktop to simplify the path. Now I think I have enough info to work this into my script using path variables I already have and a repeat statement to step through a list of plist files.

This is going to be in a larger script that I have made that currently is using a lot of GUI scripting, which I’m sure is slower than doing it this way, to tag and process images. I’m going to try tagging images by setting this value in each images plist file then open the session and process the images that are tagged. This will avoid the GUI Scripting from having to step through sometimes hundreds of images one at a time.

Thanks for you help as always,
Mark