Special thanks to Axel and Luther for their help.
-- Cleans the Cookies.plist (Safari) by removing the unwanted cookies. Warning: crawls a bit!
set GoodCookies to {"nytimes.com", "apple.com"}
tell application "System Events"
set PLContents to contents of property list file "~/Library/Cookies/Cookies.plist"
set PLValue to value of PLContents
set NewPLValue to {}
repeat with R in PLValue
repeat with k in GoodCookies
ignoring case
if |Domain| of R ends with k then set end of NewPLValue to contents of R
end ignoring
end repeat
end repeat
set NewPL to make new property list item with properties {value:NewPLValue}
make new property list file with properties {name:"~/Desktop/Cookies.plist", contents:NewPL}
end tell
Now, am I correctly getting the gist of this plist in System Events by saying (compiled from your comments):
The Cookies.plist is constructed as: [<array>...</array>] = list and [<dict>...</dict>)] = record.
Script's structure:
Read contents of property list file / format
Read value of property list item ('root' dictionary/record)
Work on individual <dict>...</dict> entries / unit of data / record
Write value of property list item ('root' dictionary/record)
Write contents of property list file / format
When you read/write 'value' of the plist file, you are dealing with the 'root' dictionary/record.
Thanks much,
Michael