How to remove .DS_Store and .AppleDouble

If you’ve shared your Windows / Unix drives with Mac OS X before, you may notice that Mac OS X will leave some footprints on your shared folders, such as .DS_Store and .AppleDouble. These files and directories are pretty annoying because they showed up in almost every single directory you accessed from the OS X.

There are two ways to solve this computer problem:

  1. Ask Apple to stop generating the .DS_Store
  2. Delete .DS_Store by yourself
  3. Set the shared folder to read-only

Apple had a tutorial on how to stop generating the .DS_Store (See here for details), however this solution requires you to run the command on every single account on every mac.

…If you want to prevent .DS_Store file creation for other users on the same computer, log in to each user account and perform the steps above…

In the other words, you will need to run the command for (# of user on each mac) x (# of mac) times!

For example, if you have 5 users on each mac, and you have 4 macs. You will need to run the command for 5 x 4 = 20 times! Also, I’ve tried this method before and the problem seemed coming back after the upgrading the system (e.g., from OS X 10.7 to 10.7.1). Therefore I decide to go with the second solution: Delete .DS_Store by myself.

How to delete .DS_Store and .AppleDouble automatically

Depending on what operating system the shared drives locate, there are two different ways to solve this problem, and they are very similar.

Situation 1: The shared folder is on Windows

If the shared folder located on a Windows machine, you may want to delete .DS_Store and .AppleDouble from the OS X. First, go to Terminal first:

Create a script


Now you are in a text editor. Copy and paste the following into the editor:

find . -name ".DS_Store"        -exec rm -Rf {} \;
find . -name ".apdisk"          -exec rm -Rf {} \;
find . -name ".AppleDouble"     -exec rm -Rf {} \;
find . -name ".AppleDB"         -exec rm -Rf {} \;
find . -name "afpd.core"        -exec rm -Rf {} \;
find . -name ".TemporaryItems"  -exec rm -Rf {} \;
find . -name "__MACOSX"         -exec rm -Rf {} \;
find . -name "._*"              -exec rm -Rf {} \;

Save the file. Don’t forget that we need to make it executable.

chmod a+x

Now you can run the script:


Unfortunately, OS X will recreate these files again after the files are removed. Therefore, I create a cron job to remove them automatically:

sudo nano /etc/crontab

and put the following:

@hourly       root /

This will tell the system to run the script hourly.

Of course, you can change it to daily, weekly, monthly etc.

Situation 2: The shared folder is on OS X or Unix

The idea is very similar. You can do the same thing except that the script will be on the server side.

Or you can simply make the shared folder to read-only. Then Mac OS X can not create any annoying files. Here is an example on how to set up a read-only shared drive on Samba:

        browseable = yes
        writeable = no
        path = /public
        force directory mode = 777
        force create mode = 777
        comment = This is a public directory
        create mode = 777
        directory mode = 777
        available = yes

Now you can say goodbye to .DS_Store and .AppleDouble.


Our sponsors:

What can you do with A8M2N-LA / NodusM-GL8E?

Recently, I decided to turn my HP m7557c computer (motherboard: A8M2N-LA / NodusM-GL8E) to an Unix server. The nightmare began. After trying nearly 10 different operating systems and distributions, I found that only very few of them worked with A8M2N-LA / NodusM-GL8E. I think it is worth to share my experience with this beast – an experiment result that took more than 100 hours.

I have not failed. I've just found 10,000 ways that won't work.
-- Thomas A. Edison
The following operating system are listed in alphabetically:

Fedora 13
Status: No
Comment: Installation went well, but the system was very unstable due to kernel panic. This mother board may not compatible with the newer Linux kernel.

FreeBSD 7.3
Status: No
Comment: Does not support USB keyword, i.e., can’t start the installation.

FreeBSD 8.1
Status: Yes
Comment: Stable, however the harddrives are very unstable. Sometimes the system complains about the harddrive. See the full story here.

FreeBSD 8.2
Status: Yes
Comment: Very stable. No problem found so far.

OS X 10.4
Status: No
Comment: Installation failed.

OS X 10.5.8
Status: No
Comment: Installation completed, but very unstable. The system reboots itself.

OS X 10.6
Status: No
Comment: Installation failed

Ubuntu 9.10
Status: Yes, stable.

Ubuntu 10.04
Status: No
Comment: If install directly from the disk, the system will not boot. The only possible way is to upgrade from an earlier version. See Ubuntu 10.04 – Can’t boot / Can’t install for details.

Ubuntu 10.10
Status: No
Comment: Cannot even load the installation disk.

Hope my experience is helpful to you.


Our sponsors: