Apple - Why are dot underscore ._ files created, and how can I avoid them?
You can't avoid them (but see the dot_clean answer by Saeid Zebardast --they can be removed from a directory if that is what you need). They're created to store file information that would otherwise go into an extended attribute on HFS+ (Apple native) or Unix/UFS volumes; in earlier Mac OS this would be the resource fork. Finder file operations will create them automatically to store the icon information, plus Time Machine stores some information in them so if you copy a file backed up via TM it will have that information copied as well.
(This is nothing new; I've noticed that XP and later leave various turds around as well, although not quite as many.)
You can use dot_clean command to remove or merge the ._ files:
dot_clean PATH_OF_FOLDER_OR_DRIVE
If you move files to linux, or have Git Bash
on your PC, and have access to the find
command, you might also be able to do this:
find . -type f -name '._*' -delete
And they're gone!
Purposes of .DS_Store and ._ files
http://diigo.com/0qiwp for an annotated view of http://lists.apple.com/archives/applescript-users/2006/Jun/msg00180.html where Matt Deatherage (a former engineer at Apple) offers explanations. Also arnotify » On the origins of .DS_Store (2006-10-01).
Since I have seen loss of user data (document content) where ._
counterparts are prevented or lost, I agree that it's:
- not acceptable to have things "vanish into the ether".
Purposes of ._ files
In addition to the purposes outlined in geekosaur's accepted answer, here are a few examples of how Apple and third party apps either use or require ._
in some situations …
File business during a copy by Finder
See my answer to a question on Stack Overflow.
NeoOffice use of deprecated codes
HFS type code NO%F
without a creator code is:
- used considerately, only where appropriate.
NeoOffice example 1
NeoOffice 3.2.1 Patch 5 save to JHFS+:
[macbookpro08-centrim:~] gjp22% xattr -l /Users/gjp22/Desktop/product\ of\ NeoOffice\ 3.2.1\ Patch\ 5.docx
com.apple.FinderInfo:
00000000 4E 4F 25 46 00 00 00 00 00 00 00 00 00 00 00 00 |NO%F............|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020
NeoOffice example 2
NeoOffice 3.2.1 Patch 5 save to a USB flash drive with MS-DOS FAT32, cleaning by BlueHarvest:
2012-05-12 06:42:08.349 BlueHarvest[31146]: Deleted ._product of NeoOffice 3.2.1 Patch 5.docx in /Volumes/FAT32/example.
NeoOffice example 3
NeoOffice 3.2.1 Patch 5 save to a volume mounted by OS X with file system type webdav
, not SharePoint, cleaning by BlueHarvest:
[macbookpro08-centrim:~] gjp22% mount | grep dav
https://www.box.net/dav/ on /Volumes/dav (webdav, nodev, noexec, nosuid, mounted by gjp22)
[macbookpro08-centrim:~] gjp22% xattr -l /Volumes/dav/product\ of\ NeoOffice\ 3.2.1\ Patch\ 5.docx
[macbookpro08-centrim:~] gjp22%
- the save by NeoOffice to the
webdav
file system did not involve an extended attribute - BlueHarvest was not required.
Hint: where Microsoft Office fails with webdav
to save to Microsoft SharePoint (see below), NeoOffice succeeds.
Microsoft use of deprecated codes
The most recent version of Office requires an HFS type code and HFS creator code when a format such as Microsoft Word (.docx
) is chosen. So — it seems that when saving to a file system that does not support those values in a com.apple.FinderInfo
extended attribute:
- Microsoft Office can not save reliably without creating multiple
._
files.
Microsoft example 1
Word 2011 14.2.1 save to a volume mounted by OS X with file system type webdav
, not SharePoint, cleaning by BlueHarvest:
May 11 18:32:49 macbookpro08 BlueHarvest[14649]: BlueHarvest started.
May 11 18:38:37 macbookpro08 BlueHarvest[14649]: Deleted ._Word Work File D_1.tmp in /Volumes/dav.
May 11 18:39:57 macbookpro08 BlueHarvest[14649]: Deleted ._Hello world, this is Microsoft.docx in /Volumes/dav.
May 11 18:42:28 macbookpro08 BlueHarvest[14649]: Deleted ._Hello world, this is Microsoft.docx in /Volumes/dav.
Microsoft example 2
Word 2011 14.2.2 (120421) saving example.docx
in the same environment:
2012-05-12 08:01:07.692 BlueHarvest[41131]: Deleted ._Word Work File D_769960778.tmp in /Volumes/dav.
Microsoft example 3
Word 2011 14.2.2 (120421) saving another.docx
in the same environment, quitting then reopening, editing then saving, editing then closing and saving:
2012-05-12 08:15:04.252 BlueHarvest[41131]: Deleted ._Word Work File D_.tmp in /Volumes/dav.
2012-05-12 08:18:48.735 BlueHarvest[41131]: Deleted ._another.docx in /Volumes/dav.
2012-05-12 08:21:12.658 BlueHarvest[41131]: Deleted ._Word Work File D_2.tmp in /Volumes/dav.
Hint: Microsoft Office 2011 fails to save to Microsoft SharePoint when the file system type is webdav
because SharePoint does not support file names beginning with a dot .
(period). See Ask Different answers to Is it possible to mount SharePoint as a volume in 10.6?
Type and creator codes: background, Apple Developer
Apple began encouraging third party developers away from type codes and creator codes more than a decade ago. In Appendix B of the File System Programming Guide, File Types and Creator Codes advises that the codes are:
generally deprecated, you may see them in legacy files and apps and in some places in the system.