Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to hide all .plist.lockfile files System 10.7
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.]
    •    
  • Currently 2.83 / 5
  You rated: 4 / 5 (6 votes cast)
 
[7,964 views]  

How to hide all .plist.lockfile files | 8 comments | Create New Account
Click here to return to the 'How to hide all .plist.lockfile files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to hide all .plist.lockfile files
Authored by: tempel on May 18, '12 08:28:53AM

Here's an even more user-friendly way to do this:

Get my app "Find Any File" (free trial from http://apps.tempel.org) and let it search for "Name - ends in - plist.lockfile". Before you click "Find", hold down the Option (alt) key so that the button reads "Find All". Click the button and enter your admin password. (If you only want to change the visibility of items in your home folder, you don't need the "All" mode, though.)

Now you'll see all those files on your disk. Switch between flat and folder view with the buttons in the top left corner.

Optionally, right-click on the list headers to enable viewing of a "Enclosing Folder" or "Entire Path" column to allow you to sort by path.

Now select the files you want to hide, then right-click on them, and choose "Make Invisble".

You can also revert this, of course, the same way.

Edited on May 18, '12 08:38:30AM by tempel



[ Reply to This | # ]
How to hide all .plist.lockfile files
Authored by: nova20 on May 18, '12 02:58:47PM

The script is free and all you have to do is click on it to run it. It does the job two or three seconds. No need to remember a sequence of actions.



[ Reply to This | # ]
How to hide all .plist.lockfile files
Authored by: tempel on May 19, '12 01:39:23AM

Oh, nothing wrong with your script. Well done.

But you should consider explaining to the unexperienced user how to even make use of your tip. There are no instructions that tell the user how to run the script.

I.e., that one needs to open Script Editor and paste that text into a new script window, then save and run it to use it. If you address people who you expect not to know how to hide files, you also need to consider they don't know how to create scripts.

My solution gives the user more control as he can see what's happening. Although, if the user doesn't care about options, yours is quicker to execute, no doubt.

Also, my tip wasn't about giving the user long instructions that he needs to remember - it shows how to use a tool to his advantage, for doing much more, and all pretty self-explanatory.

Edited on May 19, '12 01:42:46AM by tempel



[ Reply to This | # ]
How to hide all .plist.lockfile files
Authored by: hypert on May 18, '12 12:41:00PM

This works until new PLIST files (and the LOCK files) are created.

OS X automatically hides certain folders/files from the Finder, notably files that begin with a period/dot ("."). I thought /usr and some other areas might be treated the same way too, unless all of those folder have had "chflags" run on them.

Is there a way to add .PLIST.LOCK files to list of files that the Finder will always hide?



[ Reply to This | # ]
How to hide all .plist.lockfile files
Authored by: nova20 on May 18, '12 02:49:42PM

Lion makes a new .plist.lockfiles only when you install and run a new app which creates a new .plist preference file or if you run an existing app the first time in Lion. Once a .plist.lockfile is created by the OS, it isn't deleted and created again - it just sits there, visible or hidden. If you notice one or more new .plist.lockfile files in one of your Preferences folders, just run the script again ant it will hide the new files as well.



[ Reply to This | # ]
How to hide all .plist.lockfile files
Authored by: scooby509 on May 19, '12 01:36:34AM
lockfiles are a standard Unix technique for locking with the "flock" system call, and you can verify this quite easily:


cd ~/Library/Preferences
perl -MFcntl=:flock -e 'open FH, "<", "com.amazon.Kindle.plist.lockfile"; flock FH, LOCK_EX; <STDIN>;' 

(I just tested with the Kindle app, anything should work.)

That will open the file, obtain a lock, and then wait for you to press enter. Launch the application or somehow cause it to access that preferences file, it will hang. When perl exits, it will close the file, thus releasing the lock. The application will continue to launch normally. (Incidentally, if you try to run this while the app has the file locked, perl will hang waiting for the lock, ctrl+C should interrupt it.)

I'm actually a little surprised that Apple chose to do this since writing to a temporary file and moving that into place avoids corruption. To prove this, in one terminal:

echo apple > foo
perl -e 'open FH, "<", "foo"; <STDIN>; print <FH>;'

Don't press enter just yet. In anther terminal do this:

echo banana > bar
mv bar foo

Now press enter in the first terminal, you'll see "apple". In fact, you can try something similar with a gigabyte sized file, and it still works. The reason is that Unix is based on inodes, and each directory entry is really a link to an inode. In addition, a filehandle that a program gets is also a link to an inode. When we did "mv bar foo", we made foo point to the content "banana", but the program's filehandle still pointed to the old inode, so it saw "apple" instead. That's why writing to a temporary file and using "mv" works so well: programs only see one consistent version of the file.

[ Reply to This | # ]

How to hide all .plist.lockfile files
Authored by: raindear on Jun 08, '12 09:48:00AM

Thank you nova20 for the useful hint and to tempel for the tip on how to use the hint.



[ Reply to This | # ]
How to hide all .plist.lockfile files
Authored by: Sven G on Aug 07, '12 03:40:13AM

BTW, it looks like these lockfiles have been deprecated in Mountain Lion: after upgrading from 10.7.4 to 10.8, I made an experiment, deleting all of them from both the main and user library's preferences folder, and none of them has yet been recreated (either visible or invisible)...



[ Reply to This | # ]