If I manually delete a .DS_Store file from a directory, what's the worst that can happen? What important information might I lose?
4 Answers
.DS_Store files are only used by the Finder to hold custom view settings for that particular folder. In most cases nothing will happen if you delete them, or at worst custom Finder view settings (icon size, position, background color, etc) will be lost.
If you are trying to maintain a 'spatial Finder' experience in OS X, you might care more, but for most users no change will be noticed.
-
6Not quite correct, comments are lost when deleting
.DS_Store
files!– akuhnCommented Nov 12, 2012 at 23:01 -
7actually, the comments are still in the
extended file attributes
, but the Finder won't try to read from there. to see yourself:mdls -n kMDItemFinderComment myfile
– mb21Commented Jun 28, 2013 at 14:14 -
@mb21, I don't see them there in El Capitan. Also, the
-n
switch doesn't work; I have to use-name
.– WildcardCommented Sep 26, 2016 at 10:09 -
1
-
4@Pacerier - The 'spatial finder' is something that old school Mac users still talk about. The Finder in Classic Mac OS was extremely good at keeping icons and folders laid out exactly the way the user left them, so that users could rely on knowing exactly where a given file was located, visually. Some people relied on this for file organization. Most other GUI OSes didn't do a great job of this, and when Mac OS X came along in 2001, it was also not great at keeping things exactly where they were put. More discussion here: arstechnica.com/gadgets/2001/04/macos-x/9/#finder– roboCommented Aug 23, 2017 at 21:48
The worst that will happen is that folder display attributes (icon positions and view settings) will go away. If you don't consider icon positions and view settings important, there is no important information stored in these files, so it is safe to delete them.
As far as I can tell, they store all the settings shown in view options in icon and list view (or parts of the settings after some of them have been changed).
In column view the options at the bottom are the same for all folders, but the arrange by and sort by modes are still saved in .DS_Store files.
Always open in means "save the previously used view mode of this folder to a .DS_Store file". It overrides the default view mode (FXPreferredViewStyle, which is often changed after closing a window). If you check "Always open in column view" and press ⌘1, the folder-specific view mode becomes icon view.
.DS_Store files also contain the default dimensions of windows, the shown parts of windows, the positions of icons in icon view, and the width of the sidebar.
Spotlight comments are stored in both .DS_Store files and extended attributes. If you delete a .DS_Store file, Finder won't see the comments, but Spotlight will.
-
Anyway to recreate the DS_Store file (after its been deleted). In particular with comments from the extended attributes? Commented Oct 2, 2014 at 1:41
-
Will deleting .DS_Store files have any consequences for Spotlight? Commented Jan 7, 2020 at 1:19
Since OS X 10.6 and so on, the format of .DS_Store
changed from text into binary and it seems to be undocumented by Apple, therefore you really don't know the exact consequences of removing such files.
But based on the information that we have, the file is basically storing information about how it displays directories and files (e.g. its position in Finder). It holds a series of records giving attributes of the files in the directory or of the directory itself (referred to as .
) in a B-tree like format.
It also stores from where the files were removed in Trash folder, so removing the DS_Store file from there, Finder won't know the original location of your removed files.
Therefore if you don't worry about how your folder is displayed in Finder, you can safely remove it. If it's DS_Store file within your Trash folder, better leave it.
If you're further interested what's exactly stored in DS_Store files, you may try to use dsstore_dump.pl
tool which can read a store file's records in human-readable format.
See also: DS_Store Format at CPAN
-
1Aha! I arrived here looking for the answer to: "If I
rm
files manually from~/.Trash
, will I leave.DS_Store
files cluttering up my drive that would have been deleted by clicking 'Empty Trash'?" If I'm understanding you right, the only consequence would be that the single.DS_Store
in the trash folder itself may become cluttered...right? :)– WildcardCommented Sep 26, 2016 at 10:12 -
@kenorb, dsstore format is at CPAN? So is it documented or undocumented?– PacerierCommented Aug 22, 2017 at 10:37
-
@Pacerier Binary format of
.DS_Store
is most likely undocumented.– kenorbCommented Aug 22, 2017 at 11:36