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.
hi! i couldnt find a way to run the file, not even as logged as root.
do you have any ideas how can i run the file? thx
Dear Ja
you said logged in as root but this is a dos batch file and the term root etc is a unix/OSX term
so you need to do this in windows
programs run cmd
then log onto the drive letter appropriately and cd \
then run the batch file you created or run the commands separately and manually
This really saved me heaps of tedious time wastage.. Thank you so much for this..
btw, i hope you don’t mind me sharing it on my site (http://www.sur3wyn.com/2011/04/how-to-delete-all-hidden-files-on-mac.html) :)
thank’s, great script !! simple, no installation, no spyware ;-)
Great little scriptlet! Just saved me from having to cough up a script of my own to clean up our shared drive that is used by 5% macs, 95% PCs. Now to figure out how to turn that ._stuff ._off!
Thanks for helping me clean up all the OSX droppings that were littering my drive!
great script. thank you!