You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Problem with Music Files on USB Drives

For years I have had a USB stick in my car loaded with mp3 files which worked perfectly. A couple of days ago I refreshed this USB drive with some new music using Finder on an Apple Silicone MBP and all heck broke loose. I erased the drive using Disk Utility and then copied the mp3s to the drive using Finder. Lo and behold the car then started to "say" that every other file was unplayable. I tried the stick on a music system at home, same issue, every other file unplayable. I then tried a different USB drive, same issue. Long story but the problem is that macOS places a duplicate named copy of every file in the USB drive with the prefix ._ and the extension .mp3 (even though they are not mp3s) and to make matters worse the files are hidden in macOS. Command + Shift + . will NOT show the hidden files on a Mac however (thanks for Windows) two Windows PCs, one W10 and the other W11, both display the hidden files. So there are hidden files on a Mac that that are not visible even if I do the Command + Shift + . Not good!!!


I cannot take a screenshot of these files on the Mac as the files do not show. However I took a screenshot on much maligned Windows and they can be seen below. These appear for every single album that I have copied so deleting them manually would not work as I have hundreds. And please note that this was not an issue in the past but I don't recall when I last refreshed that USB drive, it's been awhile. My research shows that this has been going on for awhile but it had not bitten me yet.


So is there something I can do while copying to avoid corrupting my USB drives with these hidden mac files that play havoc on other systems, cars, home stereos, etc?


As an example, using a Windows computer to display an album one can see 11 hidden files (not visible on a Mac even with hidden files "showing"), all mp3s, all 4KBs, and somehow placed there by macOS after copying the real 11 music files. The cars and the home stereos try to play these files but are unable and display an error. Any ideas on how to avoid this? I found an app called BlueHarvest that removes these files, the issue is know, is that the only way?




I tried running a batch file on a USB drive in W11 in an attempt to delete these files but was unsuccessful. Here is what I tried:


D:

cd D:\

del /s /q ._*.*


Thanks for any help.


Posted on Jul 22, 2023 6:16 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 22, 2023 6:27 PM

I'm not sure how you managed to not have this problem before. You may have installed BlueHarvest which would prevent writing them. If you don't write the files with Finder, I think you can avoid it, but I'm not certain.


Before ejecting, run this command replacing volumeName with the name of your usb stick. If it has spaces in the name, enclose the full path in double quotes


dot_clean -m /Volumes/volumeName

Similar questions

45 replies
Question marked as Top-ranking reply

Jul 22, 2023 6:27 PM in response to elcpu

I'm not sure how you managed to not have this problem before. You may have installed BlueHarvest which would prevent writing them. If you don't write the files with Finder, I think you can avoid it, but I'm not certain.


Before ejecting, run this command replacing volumeName with the name of your usb stick. If it has spaces in the name, enclose the full path in double quotes


dot_clean -m /Volumes/volumeName

Jul 23, 2023 7:41 PM in response to elcpu

elcpu wrote:

I erased the drive using Disk Utility and then copied the mp3s to the drive using Finder. Lo and behold the car then started to "say" that every other file was unplayable. I tried the stick on a music system at home, same issue, every other file unplayable. I then tried a different USB drive, same issue. Long story but the problem is that macOS places a duplicate named copy of every file in the USB drive with the prefix ._ and the extension .mp3 (even though they are not mp3s) and to make matters worse the files are hidden in macOS.


The Finder sees that the external drive does not use a Mac filesystem. It is trying to preserve some extended attributes that a Mac filesystem would maintain, by creating


  • FOO.MP3 – the main file
  • ._FOO.MP3 – the extended attribute file


The idea being that if you ever copy files back to the Mac, it can transparently combine the data from these two files, to preserve the extended attributes.


macOS is based on Unix, and adding a leading '.' (s a standard Unix convention for hiding a file from regular directory listings. The ._FOO.MP3 name represents an attempt to create a hidden file with a unique name that is easy to associate with the main file.


Unfortunately, other systems don't know about the Finder's "._" games, and may not even know about the Unix convention for hiding a file by starting its name with a "." They see the .MP3 suffix, conclude that the extended attribute files are MP3 files, and of course, then discover that these "MP3" files are hopelessly corrupt.


The same issue happens with preparing thumb drives and memory cards for use with HDTVs and digital picture frames. The ._*.JPG files look like corrupt JPG photos to many third-party devices.


The solution is to go into Terminal just before you eject a memory card or USB flash drive.

  1. Go to that volume. (E.g., type cd and a space, then drag-and-drop the memory card or USB flash drive icon.)
  2. Do a rm ._*.* to get rid of all files with a leading ._
  3. Do a ls -a to identify any remaining files that begin with a .
  4. Do a rm on any such files other than . or .. (in Unix, . means the current directory and .. is the parent directory)
  5. In the Finder, eject the memory card or flash drive without doing anything else first.


For a MP3 or JPG file, you don't lose all that much by trashing the extended attributes file – even if you do decide to later copy the file back to the Mac.

Jul 22, 2023 8:28 PM in response to elcpu

For my 3D Printer, I created a Shortcut that I use to Clean & Eject the USB stick.

The code in the shell script:

args = ("$@")
if [[ $# -eq 0 ]]
	then args=("/Volumes/Prusa_Mini");
fi
for v in "${args[@]}"
do
	dot_clean -m "$v"
	diskutil eject "$v"
done


You can add a Shortcuts menu to the Status Menu area in the Menubar. You can also, ctrl-click on the drive and choose the Shortcut to clean and eject. Just change the path in the args= line to match your volume.

You can probably add lines to remove .DS_Store, .Trashes, and .Spotlight-V100, but if they don't cause any problems, probably leave alone.


For the checking part, if you just open the window and show hidden files (cmd-shift-. ), it won't write .DS_Store or the metadata (._) files. The metadata files only get written when you write the file.

Jul 24, 2023 6:55 AM in response to Servant of Cats

FYI... With big help from Barney-15E and MrHoffman (here and in the Lounge) I have created a Shortcut to delete all ._ files and all .DS_Store files and it works well from the Menu Bar. In order to verify I have to move the drive to the much maligned Windows which does show ALL hidden files in contrast to macOS which only shows some, grrr....


Jul 22, 2023 6:39 PM in response to Barney-15E

I have never installed BlueHarvest. In hindsight this is how I think I avoided the issue. I had an older MBP (2014) but also a W10 computer. I kept my music library in the W10 PC prior to buying this M1 MBP in late 2021 and then moved the music library to the new MBP. So I likely avoid it by going from W10 to USB and have not likely refreshed the car's drive since late 2021. Now with the new Mac, grrr...


I am going to try your Terminal command and see. I have to run it and then connect the drive to a Windows PC to see if the files are gone. There are also redundant junk like DS_Store files and others but they do not seem to be an issue. Will get back here in a bit and let you know, thanks!!!

Jul 22, 2023 6:42 PM in response to elcpu

You can delete the .DS_Store file and if you don't sort or do any other manipulate with the Finder, it should not write that back to the drive. It stores the information on how you want to display the folder in the Finder. If you don't alter the default view, it should not write another file.

You'll still have .Trashes and maybe a .Spotlight-V100.

Jul 22, 2023 7:21 PM in response to elcpu

I can understand the Spotlight issue. It should not affect anything. It will fail because it cannot read inside the directory.


The pathname error sounds strange. You should get a directory not found error.

I'll try to see if I can replicate that and figure out what is wrong. I think it is just reporting an error trying to get into some other sub-directory.


With the space, the command would be:

dot_clean -m "/Volumes/MINI 64/"



Jul 22, 2023 8:54 PM in response to Barney-15E

This is above my pay grade so I don't quite follow. Are you saying that I can use your whole script as-is above and just change the first line to args = ("mini64")? Does not seem right to me so would you please clarify?


i.e., If I want to create a shortcut to clean and eject a USB drive named mini64 after copying music files into it what would I specifically include in the shortcut?

Problem with Music Files on USB Drives

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.