How to make Mac stop copying useless ._ files

When I copy files from my Mac to an external drive, it always leaves these annoying data files everywhere. For example, if I copy files A.mp3, B.txt, and C.ppt, it will copy those files as well as ._A.mp3, ._B.txt, and ._C.txt. What is this crap and how do I make it stop?

I believe those are related to resource forks. Try opening a terminal session and using the mv (move) or cp (copy) commands.
I don’t have a Mac so I can’t test this.

As for what they are :

The Mac uses a file system in which files can contain a variety of stuff. Not only is there what you think of as the file itself, but there are other details that are kept with the file (mostly used by the Finder, such as knowing that a particular file should be opened only with a specific app).
Other file systems may not support all those details being kept with the file. Therefore, when the file is copied to a disk with that file system by the Finder, it’ll keep that information in a secondary file. Files starting with a ‘.’ are commonly hidden for most operating systems, and using the ‘_’ lets the OS X know that it’s one of the special files.
As for how to avoid them:

  1. Format the external drive to a compatible file system (i.e. HFS+). Obviously you can’t do this if the external drive can’t be reformatted for whatever reason. This also wouldn’t work if you need to work with an OS that doesn’t work with HFS file systems.

  2. Use another method to copy them instead of the Finder. Not altogether pleasant if you don’t know the command line. There may well be a GUI or one of those Finder replacements that does this for you. The problem with this approach is that it will ‘break’ some files. If you copied over all your files without the ._ and then copied them back to your Mac, it would not work correctly (which is why it’s done in the first place).

  3. Find some utility that strips those files after you copy them. Runs into the same problem as #2.

Files that start with a “.” are meant to be hidden by default.

It seems like your problem with them mostly has to do with the way they clutter up the visual appearance of a directory. The obvious solution is to just make them hidden again. I don’t know what non-Mac OS you’re using, but you probably had to do something to it to make hidden files show up in the first place. If seeing those files annoys you, just hide them again. They won’t hurt anything.

you’re correct, but AFAIK they only get created on filesystems which don’t support more than one data stream (like FAT32.) I seem to remember that in theory NTFS is able to correctly handle Mac files by using Alternate Data Streams, but I don’t know if OS X has write support for NTFS volumes yet.

I also seem to recall that later versions of OS X set the “hidden” attribute on its .dotfiles so by default Windows Explorer should hide them.

So, suck it up then? We have a Mac and a PC working together in our office–a NAS device is where we keep everything. I have hidden files turned on by default on my PC and hate the clutter that results from the Mac. The NAS is a Linux-based machine, but I believe it’s storing things in NSTF (probably for easier out-of-the-box compatibility with PCs). Nothing I can do but turn hidden files off?

I’m not sure it would be using NTFS if it’s a NAS.
Those typically use ext2 or ext3 and serve over Samba.
Not much you can do AFAIK, except for run some job on the NAS that occasionally does something like this:

find /my/smb/path -name ‘._*’ -exec rm {} ;

That will clean all of the ._ files out in one shot.

Here’s how to turn 'em off permanently on the Mac side.

It only does this for network shares, not for directly connected drives. Seems to be what you’re looking for. The command in the previous post should only need to be run once after changing this. FYI, I’ve never used this command so YMMV.

This hint only stops the creation of .DS_Store files. It won’t stop the creation of other “.” files, which contain the resource fork.

Dammit! Yeah, my bad, I didn’t really look into the problem too hard. Looking further there seems to be no way of turning off the ._ files for the entire system. There is some mention that they are only created for comments and for image previews and such, as they’re kind of what resource forks used to be. So maybe turning off ‘create document preview’ in the apps that are saving the files might go some way to mitigating the problem?

I can confirm this is the case.

I made the change suggested in that hint quite a while back, and it does suppress the .DS_Info files, it does not suppress ._* files.

That’s the file with Finder stuff, like icon position and label color. Nothing in that file you really need.

ETA: No, you can’t really avoid them easily by turning off preview. There are other extended attributes that OSX stores there. There are ways to strip xattrs while copying from the command line, however. OSX might insist on creating an empty fork anyway.

But the forks aren’t necessary, as evidenced by the fact that you can download those same files online from other systems that don’t use the system.

I could have sworn that, before, all these files were saved to a different directory. It was easy to just delete that directory: I did it all the time whenever I used my Flash drive on a Mac at school. And, yes, my files continued to work. The extension was sufficient information for any App I used.

This was back on a PPC Mac, though

BTW, how stupid is the Mac OS if it thinks starting a file with a . makes it hidden on FAT32? Even Linux understands the hidden flag.

The evidence you provide is simply evidence that resource forks are going out of style in the Mac world.

Used to be that all Mac applications had two forks in their files, with resources such as the GUI elements in a separate fork from the rest of the app. That is no longer popular and pretty much discouraged, probably because of the incompatibility it creates with other systems.

And the fact that an app with resource forks can be downloaded doesn’t mean that the fork is supported in the other filesystem either. That’s one of the reasons why Mac applications typically are downloaded in the form of a mountable disk image file: the FS of the intermediaries doesn’t matter; once OS X mounts the file as a disk, its internal FS is used.

OS X does understand the hidden flag and they use it. However, it uses “.” for files because there are other filesystems out there besides FAT32, and they were looking for a mechanism that would be good enough for most of them.

Another thing to watch out for when copying folders on a Mac is Finder makes an exact copy of the source folder when you drag it to a destination folder of the same name. If there are existing files in the destination folder that don’t exist in the source they will be DELETED.

For example, if you have a folder called Test with subfolders A, B, and C and copy that folder to a folder called Test on another drive that contains folders C, D, and E, the destination Test folder will wind up with subfolders A, B, C, a perfect copy of the source and NOTHING else.

I guess the Mac copy is really a copy and what Windows does is really a merge.

and endless wars have been fought on message boards everywhere about which approach is “correct.”