• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AppleScript to Delete Preferences in Mavericks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AppleScript to Delete Preferences in Mavericks


  • Subject: AppleScript to Delete Preferences in Mavericks
  • From: Bill Cheeseman <email@hidden>
  • Date: Sun, 10 Nov 2013 13:04:38 -0500

Many of us have discovered that application preferences are often cached in Mavericks in such a way that deleting the preferences file itself does not immediately reset the application's preferences. In fact, Apple engineers have now told us that we really were never supposed to just delete preferences files.

As a developer, I often need to completely clear application preferences to test my applications. So of course I wrote an AppleScript to do the job for me in Mavericks. Here it is:

-- Delete Preferences For Application
-- Version 1.0.0 2013-11-10
-- Bill Cheeseman

(*
Starting with Mavericks, application preferences may be cached in such a way that deleting a preferences file is not immediately effective. This script for OS X 10.9 Mavericks immediately removes any cached preferences for the chosen application and then deletes the preferences file or files. The script reports whether cached preferences were found and deleted before giving you the option to delete the preferences file or files. The application must not be running. Authentication with an administrator password is required.
*)

use scripting additions

choose application with title "Delete Preferences for Application" with prompt "Choose an application:" as alias
set info to (info for result)
set displayName to displayed name of info
if application displayName is running then
display alert "\"" & displayName & "\" is running." message "Preferences should not be deleted while the application is running. Quit application \"" & displayName & "\" and run this script again." buttons {"OK"} default button "OK"
else
set bundleID to bundle identifier of info
try
do shell script "defaults delete -app " & quoted form of displayName with administrator privileges
display alert "Cached preferences of \"" & displayName & "\" were deleted." message "You can now delete the preferences file." buttons {"Cancel", "Delete"} default button "Delete" cancel button "Cancel"
on error errMsg number errNum
if errNum is 1 then
display alert "\"" & displayName & "\" has no cached preferences." message "You can delete the preferences file." buttons {"Cancel", "Delete"} default button "Delete" cancel button "Cancel"
end if
end try
do shell script "rm -rf ~/Library/Preferences/" & bundleID & "*"
end if

-- 

Bill Cheeseman - email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: AppleScript to Delete Preferences in Mavericks
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: Mavericks AppleScript Editor formatting problems redux
  • Next by Date: Re: Universal Scripts Backup
  • Previous by thread: Re: Mavericks AppleScript Editor formatting problems redux
  • Next by thread: Re: AppleScript to Delete Preferences in Mavericks
  • Index(es):
    • Date
    • Thread