How to prevent accidental removal of certain files and folders in Mac OS X
You could check the "locked" checkbox in the "Get Info" dialog. ctrl-click or secondary mouse button on the file -> "Get Info" -> check the "locked" checkbox.
Another way of protecting the file would be setting the immutable flag via command line:
$ chflags uchg <file>
Checkout http://osxfaq.com/Tutorials/LearningCenter/AdvancedUnix/ugp2/page2.ws and
$ man chflags
Unset the “writable” flag, or better yet, make them the property of the super user:
chmod -w [your files here]
sudo chown root:root [your files here]
You can also use the Finder‘s “File info -> Sharing and permissions” fields to change the file permissions.
To prevent accidental removal of files in a folder, I have ended up with doing both the suggestions.
- Make read only
- Mark as locked / Set the uchg flag
To prevent the folder itself to be removed I have only found marking it as Locked to help. This however also prevents you from adding files to that folder, which might be a bit of a hassle. But it does force you to uncheck and check that flag every time you want to do something in that folder, which might be a good idea if you don't do it too often.