I’ve written a simple batch file to remove those hidden files that Mac OSX leaves all over shared drives to annoy us Windows users.
del /s /a:h ._* :: http://en.wikipedia.org/wiki/Resource_fork del /s /a:h .DS_Store :: http://en.wikipedia.org/wiki/.DS_Store del /s /a:h .Trashes :: http://en.wikipedia.org/wiki/Recycle_bin_(computing) @pause
How to use
Copy the code into a text file, rename it cleanOSX.bat and run it from the root of the drive you wish to clean. The script will look through all subfolders, deleting any hidden file or folder with a name that begins with ._, or that matches .DS_Store or .Trashes. Depending on the number of these files on your drive, the process of deleting them could take some time.
Where do these files come from?
The resource fork
The resource fork is a construct of the Mac OS operating system used to store structured data in a file, alongside unstructured data stored within the data fork. A resource fork stores information in a specific form, such as icons, the shapes of windows, definitions of menus and their contents, and application code (machine code). For example, a word processing file might store its text in the data fork, while storing any embedded images in the same file’s resource fork. The resource fork is used mostly by executables, but every file is able to have a resource fork.
Currently, Mac OS X does support resource forks on Windows SMB shares by creating a hidden file in the same directory with the data fork file, with the characters “._” at the beginning of the file name. However, this may be annoying for some users, especially because some Windows power users always keep hidden files visible. Besides, Windows does not treat those files correctly as the file itself is moved or removed.
The Desktop Services Store
.DS_Store (Desktop Services Store) is a hidden file created by Apple Inc.’s Mac OS X operating system to store custom attributes of a folder such as the position of icons or the choice of a background image.
The Trash folder
Under Mac OS X, when a file is deleted in Finder, it is moved to a .Trashes folder, and when viewing the device’s available space the space occupied by the deleted files is shown as occupied.