PlistLib – Preference File Library
PlistLib
PlistLib is a free AppleScript library of essential functions to manage preference list files from within AppleScript code.
Use System Events and some “defaults” shell script plist commands to manage plist’s from within AppleScript scripts and applications. Verify, create, modify, and delete plists and their key:value pairs easily with these ready-made routines.
Library Handlers
- VerifyPlist ( _folder , _file ) – Return plist path. Plist file is created if it does not exist.
- CreatePlist ( _folder , _file ) – Create empty plist file and return plist path.
- ValidPlistPath ( _folder , _file ) – Return a validly formatted plist path as text.
- ValidPlistDomain ( _path ) – Change a plist path to a plist domain – POSIX path of path and file without the “.plist” extension. For use in “defaults” shell script commands.
- WritePlist ( _path , _thePlist ) – Write a key:value pair according to the value kind: boolean/data/date/list/number/record/string.
- WritePlistValue ( _path , _key , _value ) – Overwrite the plist contents with the passed plist dictionary (AppleScript record). Uses “defaults” shell script command.
- ReadPlistValue ( _path , _key ) – Return the value associated with the key.
- ReadPlistName ( _path , _key ) – Return the name associated with the key.
- ReadPlistText ( _path , _key ) – Return the text representation associated with the key.
- ReadPlistKind ( _path , _key ) – Return the kind associated with the key.
- ReadPlist ( _path ) – Return the entire plist (all of the “defaults” for the domain). Uses the “defaults” shell script command.
- ModifyPlistValue ( _path , _key , _value ) – Modify the value of a plist key:value pair.
- ModifyPlistSubValue ( _path , _key , _subKey , _value ) – Modify key:value (_subkey) of a plist key:value (_key).
- RenamePlistKey ( _path , _oldKey , _newKey ) – Renames the old_key to the new_key via “defaults” shell script command.
- DeletePlistKey ( _path , _Key ) – Removes the key:value pair associated with key from plist.
- DeletePlistContents ( _path ) – Removes all defaults information for domain. Uses “default” shell script command.
Free AppleScript Library
PlistLib code: Copy the selected code (click on Select All to highlight all the code) to the clipboard and paste it into a newly created AppleScript document. Download code FREE as a text file from here.
Comments
PlistLib – Preference File Library — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>