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 23, 2023 7:41 PM

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.

Similar questions

45 replies
Question marked as Top-ranking reply

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 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 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 23, 2023 9:02 PM in response to elcpu

elcpu wrote:

Many thanks. I can follow your logic above except the drag and drop of the USB drive icon into Terminal. I have not done that before and I am not sure how.

The shortcut I already got deletes all the ._ files and that removes the problem. The shortcut is a Terminal script:

dot_clean -m "/Volumes/USB MUSIC"
diskutil eject "USB MUSIC”


You don't need to do it the long way. I probably should use dot_clean -m.


The drag-and-drop thing is a useful feature of Terminal that helps with the need to escape, or quote, special characters in file names and directory names. If you drag a file, folder, or volume icon from the Desktop or a Finder window to the Terminal window, and drop it there, Terminal will paste in the file, directory, or volume path name, at the current text insertion point. Complete with any characters needed to make the shell recognize the name as being a single argument.


For instance, if you had Finder { Preferences / Settings } configured to show flash drive icons on the Desktop, you could type dot_clean -m in the Terminal window, add a space after that, and drag your drive's icon to the window. I think the command line would then show something like


$ dot_clean -m /Volumes/USB\ MUSIC


As far as the shell is concerned, this would be equivalent to


$ dot_clean -m "/Volumes/USB MUSIC"


Double-quotes around the whole string, or escape (\) characters in front of particular characters that would pose an issue, serve the same purpose.


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

Servant of Cats wrote:

The drag-and-drop thing is a useful feature of Terminal that helps with the need to escape, or quote, special characters in file names and directory names. If you drag a file, folder, or volume icon from the Desktop or a Finder window to the Terminal window, and drop it there, Terminal will paste in the file, directory, or volume path name, at the current text insertion point. Complete with any characters needed to make the shell recognize the name as being a single argument.


That is very good to know.


For instance, if you had Finder { Preferences / Settings } configured to show flash drive icons on the Desktop, [I do]<< you could type dot_clean -m in the Terminal window, add a space after that, and drag your drive's icon to the window. I think the command line would then show something like

$ dot_clean -m /Volumes/USB\ MUSIC


It did just that but why the $ sign above? What does the $ mean?


As far as the shell is concerned, this would be equivalent to

$ dot_clean -m "/Volumes/USB MUSIC"

Double-quotes around the whole string, or escape (\) characters in front of particular characters that would pose an issue, serve the same purpose.


I just tried it and it worked, thanks again.... (I don't have anymore Helpfuls to give or I would give you one)

Good suggestions, keep them up - hope to see you in the Lounge soon. 👍

Jul 24, 2023 6:58 AM in response to elcpu

elcpu wrote:

Servant of Cats wrote:

For instance, if you had Finder { Preferences / Settings } configured to show flash drive icons on the Desktop, [I do]<< you could type dot_clean -m in the Terminal window, add a space after that, and drag your drive's icon to the window. I think the command line would then show something like

$ dot_clean -m /Volumes/USB\ MUSIC

It did just that but why the $ sign above? What does the $ mean?


That's just part of the prompt, to let you know that the shell is waiting for you to type in another command. The bash shell ("Bourne Again Shell"; the name is a pun) uses "$"; other shells like csh might use "%".


The part in front of the "$" or "%" where it shows you the name of your Mac, and the current directory, is done using stuff in the default shell initialization scripts that customizes the prompt.


Back in the days when text terminals ruled, many power users would have objected to having "John-Does-Mac" take up space on every command line. They might have gone with something as minimal as just the "$" or "%" (after all, you could always do a pwd to show the current directory).


Jul 24, 2023 6:01 PM in response to tbirdvet

tbirdvet wrote:
I have no issue copying the files to a USB2.0 flash drive...


The problem is not copying the files, the problem is that the music files copy with extra garbage whether you see them or not (read this whole thread from Page 1 or go to the Water Cooler and read tt2's, MrHuffman, and KiltedTim's posts). Your Mac Studio will not display the files even if you unhide them with Command + Shift + . but the junk files are there. Windows does show them if you unhide files.


Terminal on your Mac Studio WILL also show you the files with the command below. Be aware that all files will display including the real music files, best to try this on a test drive with a dozen or so songs only. Copy the songs from your Mac to a USB drive, do not eject the drive just yet, open Terminal and type the command below (replace USBDrive with the name of the drive you are using):


ls -Ral@ "/Volumes/USBDrive/"


There are apps on the app store to remove the offending ._ files. My wife's car ignores them but my newer car does not and neither does a new music system I just bought for my home office.


The Mac Shortcut I wrote (shown previously on this thread) removes the offending files with one click and ejects the drive ready to use on any system.

Jul 23, 2023 10:29 AM in response to Barney-15E

I bought the $1.99 app that Kilted Tim recommended. It deleted the ._ just like our script and also deleted the .DS_Store files, not that they make any difference. It did NOT delete other "hidden" files although the app said it would remove all - it left various "hidden" files at the root of the USB drive like Spotlight and Trashes which are easy enough to delete in W11, again not that they make any difference.


Thanks again...

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/"



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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.