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

Jul 23, 2023 10:20 AM in response to elcpu

rm "/Volumes/USB Music/.DS_Store"

That needs to go before you eject it.


-m deletes the metadata files instead of trying to merge them which can’t be done on that file system. Apple stores the metadata with the file. On file systems that can’t do that, it splits them out as ._ files. If you copy back to a Mac file system, it would automatically merge them into the copied file.

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 23, 2023 11:08 AM in response to tbirdvet

tbirdvet wrote:
I put music on my thumb drive to use in my car all the time. What I do is have the drive formatted to fat32 then I open music, copy the songs then paste into the drive. No issues.


That is how it used to work for me using a PC to copy the files but that is no longer the case using a Mac. It does not work on my 2018 Honda CR-V with a fancy head unit or my home music systems as they try to read the hidden .mp3 files. However my wife's very old CR-V (2010) does work even with those junk files, the head unit skips them although the display shows a wrong song count. Deleting the ._ mp3 hidden files takes care of the issue for my newer CR-V and the home music systems. What car do you have?

Jul 23, 2023 11:35 AM in response to elcpu

elcpu wrote:
Barney-15E wrote:
rm "/Volumes/USB Music/.DS_Store"
That needs to go before you eject it.

That did not work, the .DS_Store files are still there. Should it be:
rm "/Volumes/USB Music/".DS_Store


Or: rm .DS_Store "Volumes/USB Music/"


There is a .DS_Store file in every single album I am copying, not just at the root of the USB drive. The command would have to find ALL of them on the drive.

Jul 23, 2023 4:34 PM in response to elcpu

What did they delete? I cannot tell from what is left.

I had a post with a scrap of a command which would have deleted the contents of the USB stick. Using the command line can be dangerous. You can be half-way through typing a command and accidentally hit return. Sometimes, that can do destructive things.


I think you had a comment about the app being able to recursively delete the .DS_Store files.

I'm not sure there was any more than that.

Jul 23, 2023 8:10 PM in response to Servant of Cats

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”

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 7:04 AM in response to Servant of Cats

Servant of Cats wrote:

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 "%".


You lost me there... Care to elaborate?

I am using zsh because that is what Barney used, does it make any difference?

Jul 24, 2023 7:44 AM in response to elcpu

elcpu wrote:

Servant of Cats wrote:

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 "%".

You lost me there... Care to elaborate?
I am using zsh because that is what Barney used, does it make any difference?


As to the pun … The original Unix shell was sh (shell). The Bourne shell was developed by a guy at Bell Labs whose last name was Bourne. ("Bourne Again shell" is to "shell" what "born again Christian" is to "Christian"; get it?).


bash used to be the default shell for macOS, but Apple stopped upgrading the version of bash they shipped with macOS … and in current versions of macOS, zsh is the default shell. The set of scripting commands you find in one shell may be a bit different from the set you find in another, which is one reason why some power users have strong preferences for one shell or another, and why you can change your default shell.


My version of macOS is old enough that bash is its default shell. But for what you're doing, if your default shell is zsh and you have a script that works with zsh, there isn't any reason to switch to another shell.


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.

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.