Created
August 16, 2012 10:55
-
-
Save itsdamslife/3369260 to your computer and use it in GitHub Desktop.
Saving information in plist through Applescript (In example: current track played in iTunes)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" | |
tell application "iTunes" | |
set mytrack to name of current track | |
set myalbum to album of current track | |
set myartist to artist of current track | |
end tell | |
-- create an empty property list dictionary item | |
set the parent_dictionary to make new property list item with properties {kind:record} | |
-- create new property list file using the empty dictionary list item as contents | |
set the plistfile_path to "~/Documents/example.plist" | |
set pl to ¬ | |
make new property list file with properties {contents:parent_dictionary, name:plistfile_path} | |
-- add the values to plist | |
tell pl | |
-- create a text entry | |
make new property list item at end with properties ¬ | |
{kind:string, name:"album", value:myalbum} | |
make new property list item at end with properties ¬ | |
{kind:string, name:"artist", value:myartist} | |
make new property list item at end with properties ¬ | |
{kind:string, name:"track", value:mytrack} | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment