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

Automatically remove "._" files from Windows shares Network
Mac OS X, when connecting via SMB, will leave ._ files on Windows shares. This can sometimes cause problems for others accessing these files, automated programs, etc. I have created a script called DotUnderscore.vbs to handle this problem. This script will monitor and delete files based on a string within the file name (e.g. ._). To use this script, I recommend creating a Scheduled Task on Windows to start it up at system startup, so it will continually run.

Here are some examples on the command line that you would pass to the script:
cscript.exe DotUnderscore.vbs C:Temp ._
That would delete all files that had ._ within their filename from the directory C:Temp. Note that directories containing spaces must have quotation marks around them, e.g.:
cscript.exe DotUnderscore.vbs "C:Documents and Settingsusername" ._
As always, test on a test directory before you put it into production. This script may or may not work with certain non-standard symbol or alphanumeric characters in the folder name.

[robg adds: Just to state the obvious, this is a script that resides and runs on the Windows server, not the Mac. These four previous hints deal with the same topic.]
  • Currently 2.33 / 5
  You rated: 2 / 5 (6 votes cast)

Automatically remove "._" files from Windows shares | 13 comments | Create New Account
Click here to return to the 'Automatically remove "._" files from Windows shares' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically remove "._" files from Windows shares
Authored by: bigkm on Jun 27, '06 08:06:59AM
or you could just drop your share onto this applescript droplet instead of ejecting it.

on run
	display dialog "Drag a removable disk icon here to have it cleaned and ejected"
end run

on open selectedItem
	-- get a text version of the volume name and remove the trailing colon :
	set volumeName to selectedItem as string
	set volumeName to characters 1 thru (the (length of volumeName) - 1) of volumeName as string
	if (list disks) contains volumeName then
		do shell script "find '/Volumes/" & volumeName & "' -name '.DS_Store' -exec rm '{}' \\;"
		do shell script "find '/Volumes/" & volumeName & "' -name '._*' -exec rm '{}' \\;"
			do shell script "rm -rd '/Volumes/" & volumeName & "/.Trashes'"
			do shell script "rm -rd '/Volumes/" & volumeName & "/.TemporaryItems'"
		end try
			tell application "Finder" to eject disk volumeName
		end try
	end if
end open

[ Reply to This | # ]
Automatically remove "._" files from Windows shares
Authored by: neuralstatic on Jun 27, '06 08:18:13AM

just to state the obvious: for active mac use, these files will jsut come back.

i guess this is handy if you know a mac will never mount that smb volume again.

[ Reply to This | # ]
Automatically remove "._" files from Windows shares
Authored by: Rilex on Jun 27, '06 09:45:32AM

The reason I made it was because a user over at Apple Discussion Forums had software that would not function with the ._ files. Since this script will constantly monitor a directory, the files would be cleaned up in time for the daily run of this piece of software.

But this script can really be used to purge any file containing any set of characters, not just "._".

[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: Hulot on Jun 27, '06 10:44:26AM
Could be a really BAD idea
Authored by: giskard22 on Jun 27, '06 09:48:24AM

Depending on what file types are in use, this is potentially a HORRIBLE thing to do. What you're doing is deleting portions of the files. The resource fork, along with any metadata like Spotlight comments, are stored in the ._ files. It's true that these days, that data isn't usually crucial to the file's main function. You'll typically find icon previews of images and that kind of thing. But still, this is potentially a very harmful action.

[ Reply to This | # ]
...and those .DS_Store files
Authored by: joshturse on Jun 27, '06 10:54:51AM
Since it's within the realm of this subject, I thought I'd remind everyone that you can prevent .DS_Store files on network volumes:

[ Reply to This | # ]
...and those .DS_Store files
Authored by: joshturse on Jun 27, '06 10:59:50AM

That's funny - someone obviously thought of the same thing I did - I just had the reply window open too long...makes me look like a dumb***

[ Reply to This | # ]
Removing "._" files only problematic in very few cases
Authored by: hamarkus on Jun 27, '06 01:34:07PM

There are only a few file types (like certain types of font files) which cause problems when robbed of their resource forks. These files are most often related to the Mac OS and it is therefore highly unlikely that one would store these on a server.
If somebody knows what files types are affected in addtion to Mac fonts, please post it here.

I have been using BlueHarvest for quite a while and never had any problems. It, however, is far from perfect. While the cleaning function works flawlessly, the prevention of the creation of new "._" files works only partly.

[ Reply to This | # ]
Authored by: kaih on Jun 27, '06 07:58:21PM
No, seriously, depending on what kind of data is stored on your server this could be a VERY BAD IDEA
If you have anything on the server that still uses a resource fork, this will break it. No questions asked. No warning given, and no chance of fixing it, other than restoring from another source.
In particular, even in our wonderful, shiny Mac OS X "resource forks are depricated" world, certain things still rely on resource forks. Microsoft Office is a Carbon app. It is not an app bundle, and it needs a resource fork. It won't launch if it's resource fork is broken.
Fonts - lots of older fonts rely on having important information in their resource forks. I've seen the results of a server where someone went through and cleaned up the dot-underscore files. No, it wasn't pretty. Their entire font collection was broken. Fortunately, they had it all on the original CDs and could recover it, but it was a pain.
Other things like custom icons, finder comments, finder labels and all sorts of other kinds of metadata is stored in these files.

Only delete these files if you really know what you're doing, and you have a recent backup. No, really...


[ Reply to This | # ]

Authored by: sjk on Jun 28, '06 12:37:52AM
Yep, don't frivolously delete "._" AppleDouble and .DS_Store files.

There's been some mention of the consequences of doing that (among other things) in the recent Metadata support thread on the darwin-dev list. It's an interesting discussion if you want to learn more about those kinds of technical details.

[ Reply to This | # ]
Automatically remove "._" files from Windows shares
Authored by: drowe on Jun 28, '06 01:01:36PM
This hint is for removing the files from a Windows share. These junk files serve no purpose on a Windows box. Windows fonts don't depend on them, Microsoft Office on a Windows box don't depend on them, they are just an annoyance.

[ Reply to This | # ]
Automatically remove "._" files from Windows shares
Authored by: kaih on Jun 29, '06 02:20:38AM

If it's purely a windows share, then these files shouldn't have been there in the first place. Remove them.
If the share point is shared between windows and os x, then removing them can potentially cause problems - if you're a windows admin and you want to go through and trash every dot-underscore file off your sharepoints, you need to be aware of the repercussions.


[ Reply to This | # ]
Updated version
Authored by: Rilex on Jul 06, '06 01:38:12PM
I've updated this script to VB.NET. The application has some requested improvements and is available at

[ Reply to This | # ]