How to hide all .plist.lockfile files

May 18, '12 07:30:00AM

Contributed by: nova20

Apple has introduced an additional type of preference file in Lion, those whose names end in ".plist.lockfile". Here is a good explanation of the function of those files: Lockfiles and other plist file subtypes in OS X Lion

Since plist.lockfiles do not contain any useful information for the user and almost double the content of and clutter the Preferences folders in /Library and ~/Library, I've been looking for a way to hide those files. With help from Yvan Koenig of MacScripter in this topic (I'm flex20 in that forum), I wrote an AppleScript "Hide Unhide plist.lockfile.scpt," which provides a quick and easy way of hiding or unhiding all those pesky files.

You will need an admin password to run the script because some of the ".plist.lockfile" files can only be changed by administrators. You can add the script to your AppleScript menu, or save it as an app, such as "Hide Unhide plist.lockfile.app," that you can keep anywhere you like, as I did.

Here's the script:

-- Hide Unhide plist.lockfile -- version 2.0

display dialog 
	"Hide or Unhide the plist.lockfile files in the Preferences folders in /Library and ~/Library." & return & 
	return & "Will require to enter an administrator password." & return with title "Hide or Unhide the 
	plist.lockfile files" buttons {"Cancel", "Hide", "Unhide"} default button 1 giving up after 60

set dialogResult to result
set giveUp to gave up of dialogResult
if giveUp is true then error number -128 -- Cancel on giving up to cancel the script.
set user_choice to button returned of dialogResult -- Set the user choice.

-- Process the user choice. Will require to enter an admin password.
if user_choice is "Hide" then
	do shell script "chflags hidden /Library/Preferences/*.plist.lockfile" with administrator privileges
	do shell script "chflags hidden ~/Library/Preferences/*.plist.lockfile" with administrator privileges
else if user_choice is "Unhide" then
	do shell script "chflags nohidden /Library/Preferences/*.plist.lockfile" with administrator privileges
	do shell script "chflags nohidden ~/Library/Preferences/*.plist.lockfile" with administrator privileges
end if
[kirkmc adds: Works as advertised. You could also just run these commands from Terminal. Look for the chflags commands in the script; there are two to hide and two to unhide, one each for /Library/Preferences and ~/Library/Preferences. I see no need to do this permanently, but it's good to know that I can if I want to, say, clean out my Preferences folder.]

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20120514084139369