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

Zap .DS_Store files to fix Finder window settings bug Desktop
Ever since I updated to 10.2, I couldn't get the Finder to remember window settings any better than in 10.1, so I decided to zap all the .DS_Store files and start over.

I used the following script to accomplish this task. I saved the script as (remember to make it executable), launched Terminal, quit the Finder and ran the script as root.
# deletes all .DS_Store files on /
for x in `find / -name ".DS_Store" -print`
rm -f $x
After restarting the finder, window positions are remembered!

[Editor's note: I haven't tested this script myself, nor have I had the window position memory problem ... but I know others have, so maybe this will help someone out there.]
  • Currently 1.00 / 5
  You rated: 1 / 5 (3 votes cast)

Zap .DS_Store files to fix Finder window settings bug | 25 comments | Create New Account
Click here to return to the 'Zap .DS_Store files to fix Finder window settings bug' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One liner...
Authored by: Hedderik on Nov 26, '02 10:13:22AM

Actually, this is a one-liner, both for tcsh and bash shells:

find / -name ".DS_Store" -exec rm \{} \;

see the ACTIONS section of the find manpage.

- Hedderik.

[ Reply to This | # ]
One liner...
Authored by: vasi on Nov 26, '02 10:34:22AM

It's usually considered more efficient to use xargs:

find / -name ".DS_Store" -print0 | xargs -0 rm


[ Reply to This | # ]
xargs is not safe
Authored by: fredcondo on Nov 26, '02 12:02:57PM

xargs will choke on any paths that contain spaces, a common occurrence on Macs. Probably the safest command on a Mac is this:

sudo find / -name .DS_Store -print -exec rm -f "{}" \;

[ Reply to This | # ]
xargs is not safe
Authored by: kent37 on Nov 26, '02 12:24:07PM

Don't the -print0 and -0 make xargs process spaces correctly?

[ Reply to This | # ]
xargs -0 is safe
Authored by: Bernd P. Ziller on Nov 26, '02 12:45:31PM

Using 'find -print0 | xargs -0' is safe.

The pathname will be printed followed by an ASCII NUL character, and xargs will use the ASCII NUL as argument separator.

Perfectly safe...

[ Reply to This | # ]
One liner...
Authored by: stoltz on Dec 02, '02 02:51:44AM
find / -xdev -name .DS_Store -print0 | xargs -0 rm -f

I prefer not to descend into network mounted drives, CDROMs, etc., hence the -xdev flag. Add /Volumes/Disk23 and such to explicitly search those disks as well.

[ Reply to This | # ]
One liner...
Authored by: gidds on Nov 26, '02 12:01:12PM
And in zsh, it's even simpler:

rm /**/.DS_Store

Everyone should use zsh!

[ Reply to This | # ]

One liner...
Authored by: rxmac on Nov 26, '02 10:13:43PM

thanks were can i find more info on zsh other than the man pages

[ Reply to This | # ]
Replace ?
Authored by: Johnny_B on Nov 26, '02 11:18:02AM

Is it possible to take a .ds_store file that is set up the way I want, and to put this in every folder, with replacing ? This would really be a "killer" hint.

[ Reply to This | # ]
Folder view settings lost
Authored by: mark.suska on Nov 26, '02 10:41:21PM

I just switched to OS X when I got my new PowerBook. One of the first things that I noticed was that the finder windows were recycled. I found and enabled the finder setting to open folders in new windows, but now I find that the settings in for each folder are sometimes lost.
[begin rant: This was one of my favorite features (remebering window and icon positions) about Mac OS and the thing I hate about Windows. Each window and icon stays where I leave it, and this is easy to remember. I hate searching through list for files, and often you do not remember the name of the file. :end rant]
I copied many folders of photographs from another machine and I wanted to have each folder open up with large icons and preview enabled so that I could browse the picures in the finder. I could not figure out a way to change the settings without manually opening each folder individually and modifying the settings. I also did not want to globally modify the setting because I had already organized many other folders.
Anyway, I painfully modified the settings one by one. The settings kept for a while but I started to notice that some folder settings were changing.
The preview and backgroung color was lost on some folders. Other folder had the preview icons decrease in resolution (they had that blocky look like enlarged OS 9 icons do).
Is there a way to fix this problem?

When you select the "Show View Options" menu (command-J) a floating window appears with these options:
- this window / all windows
- icon size (28 to 128)
- text size
- label position (bottom / right)
- snap to grid
- show item info
- show icon preview
- keep aranged by (name / date / size / kind)
- background (white / color / picture)
In addition to these options, the position and size of the finder window and the positions of each icon are stored.

Where are each of these settings stored?
Does anybody know what exactly is stored in the .DS_Store file?
If you view the .DS_Store file you will see files listed, so it does store some per-file settings.
I thought that the file system itself stored all this information. Mac OS 8/9 did this without the .DS_Store files. OS X still uses the same file system as previous Mac OS versions, so why is the .DS_Store file needed?
The only new settings introduce in OS X is the Preview and Background.


[ Reply to This | # ]
Folder view settings lost
Authored by: aranor on Nov 27, '02 02:45:01AM

OS X does /not/ use the same desktop database as OS 9. It uses the .DS_Store files instead.

[ Reply to This | # ]
How to save as script?
Authored by: mediaman on Nov 26, '02 11:44:50AM

How do you save this as a terminal script? Or where can I find info on how to save terminal scripts?

[ Reply to This | # ]
How to save as script?
Authored by: thinkyhead on Nov 26, '02 08:09:25PM

1. put the script into a text file.
2. make sure the text file has unix linefeeds
3. make sure the script starts with #!/bin/sh (preferably)
4. "chmod u+x filename" to make it executable by its owner
5. put the script into a folder included in the execution path

Q: How do I get Unix linefeeds?
A: Edit with pico, vi, joe, or BBEdit (which has unix as an option)

Q: What folders are in the execution path?
A: "echo $path; echo $PATH"

Q: What if I want everyone to be able to execute my script?
A: "chmod a+x filename" ... or better "man chmod"

[ Reply to This | # ]
How to save as script?
Authored by: hembeck on Nov 26, '02 11:22:59PM

Once more in english :)

[ Reply to This | # ]
How to save as script?
Authored by: mediaman on Nov 27, '02 04:49:02PM

Thanks for the info. Much needed =:0)

[ Reply to This | # ]
Easier, for me anyway
Authored by: Xeo on Nov 26, '02 12:56:01PM

sudo find / -name ".DS_Store" -remove

[ Reply to This | # ]
Oops, not
Authored by: Xeo on Nov 26, '02 12:58:56PM

Sorry, I got "remove" in my head but it's really

sudo find / -name ".DS_Store" -delete

[ Reply to This | # ]
if you use a loop quote the variable
Authored by: ber on Nov 26, '02 05:43:03PM

Presumably the original hint is using a for loop to protect against spaces. The other replies show alternatives. But if you do use the for loop then you need to quote the loop variable.

rm -f \"$x\"

[ Reply to This | # ]
if you use a loop quote the variable
Authored by: ber on Nov 26, '02 05:44:37PM

Damn where did those backsklashes come from. Lose them.

[ Reply to This | # ]
if you use a loop quote the variable
Authored by: prk on Nov 26, '02 06:56:06PM

I noticed that the stripslashes() PHP function was not being called for the titles, but gesh, in the comment also. Someone should fix that.

[ Reply to This | # ]
Finder window view settings lost
Authored by: mark.suska on Nov 26, '02 10:54:29PM

I just figured out why some preview icons appear as a low resolution blocky icon.
I had viewed the pictures in GraphicConverter and it had automatically replaced the icon images with its own preview icons. Unfortunately these icons do not look good in OS X.

Now I am trying to figure out how to get rid of those icons. Argh!
Any ideas?

This still does not solve the problem of finder view settings being lost.


[ Reply to This | # ]
Finder window view settings lost
Authored by: cowboy on Nov 26, '02 11:44:00PM

Not sure if this would work, but its worth a try...

I've been using Pic2Icon. It can take a folder of images and create OS X preview icons.

Hmm.. I see somebody at versiontracker has had problems with it recently. It has worked perfectly for me (4.8 stars at versiontracker with 107 reviews). It is freeware.

[ Reply to This | # ]
Finder window view settings lost
Authored by: haighy on Nov 27, '02 08:47:16AM
I occasionally get that chunky preview problem too, when going through old System 9 images. One way to fix it is by zapping the resource fork, where the low-res icon is being stored. The Finder then automatically generates a nice icon (if it's in a common image format, such as JPEG or TIFF).

You can use Grim Ripper to delete the resource fork. Like the documentation says though: it can be destructive if you don't know what you're doing, so perhaps best to try it on a copied file first.

Wins Scariest Icon award too.

[ Reply to This | # ]

Authored by: VEGx on Nov 27, '02 05:04:13AM

make the script and append it with an extension ".command"
Now all you have to do is CLICK on it in!!!

You still have to make it "executable." But you don't really have to worry about "$PATH" and whatnot.

[ Reply to This | # ]
Is there one for the top level?
Authored by: ajmas on Nov 28, '02 01:30:21PM

Does anyone know where the .DS_store for the Computer ( or top level ) directory is? I can't get it to keep my settings, so any suggestions would be appreciated.

[ Reply to This | # ]