Looking for Files with Blank Metadata

This is a fun one, but here goes:


I have an indeterminate number of corrupted music files hanging out on my hard drive. By "corrupted" I mean that while they look fine in the Music app, they don't play; the app just skips over them and pretends like nothing happened. When you locate the file itself, Preview doesn't work. You hit the space bar and it gives you just a shot of the album art, if any exists.


One thing I eventually noticed about the corrupted files is that some of the metadata that should be present against each file isn't, in fact, there, when you view info about the file in Finder. For example, a "good" file will show:

    • Created
    • Modified
    • Title
    • Duration
    • Authors
    • Audio channels
    • Sample rate
    • Album
    • Musical Genre
    • Year Recorded

While a "bad" file off the same album shows:

    • Created
    • Modified
    • Last opened
    • Duration
    • Audio channels
    • Sample rate

As such, it seems to me that if I could search my entire music collection for tracks where the pieces of metadata are blank, I could round up the problematic tracks fairly quickly, but I haven't yet figured out a way to do that. Any help would be appreciated!

MacBook Pro 16″, macOS 12.1

Posted on Jan 17, 2022 7:32 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 17, 2022 9:06 AM

If you had the free ExifTool installed, you could ask it to show you the filenames of those audio files that are missing some or all of the following information:


exiftool -s -Filename -if '(not $Title or not $Artist or not $AudioSampleRate or not $Album or not $Genre or not $MediaCreateDate)' -ext mp3 -ext m4a *.{mp3,m4a}


Which produces this output:


Because the only .m4a has all of the tested fields filled, and thus fails the condition(s), and two .mp3 have some of the fields missing, and satisfy the test, resulting in output.

Similar questions

8 replies
Question marked as Top-ranking reply

Jan 17, 2022 9:06 AM in response to bluejays47

If you had the free ExifTool installed, you could ask it to show you the filenames of those audio files that are missing some or all of the following information:


exiftool -s -Filename -if '(not $Title or not $Artist or not $AudioSampleRate or not $Album or not $Genre or not $MediaCreateDate)' -ext mp3 -ext m4a *.{mp3,m4a}


Which produces this output:


Because the only .m4a has all of the tested fields filled, and thus fails the condition(s), and two .mp3 have some of the fields missing, and satisfy the test, resulting in output.

Jan 17, 2022 10:48 AM in response to bluejays47

Try the following in Terminal:


The magic is in the not equal to anything !='*' portion.


mdfind -onlyin ~/Music "kMDItemAlbum !='*'" -name .m4p > results.txt


It returns the full path to each file it finds which I am sure you will find useful. If you run it without the "> results.txt" you can peruse the results in the terminal instead of dumping the results to the results.txt file.


You can read up on the mdfind command by issuing "man mdfind" to view the manual page. You can also issue the "mdimport -X" command to get a schema list of all the metadata kMD attributes.

Jan 17, 2022 10:25 AM in response to VikingOSX

So, if I'm parsing that string correctly, it should return any MP3 or M4A files that are missing any (not all) of the listed categories. If that's so, something's not quite right, in that it's returning "no matches found: *.mp3" which doesn't wash as even if I've already whack-a-mole'd all of the corrupted files, I do still have tracks in my library without genre info, and those would at least pop up here, right?

Jan 17, 2022 10:39 AM in response to bluejays47

The assumption is that the candidate audio files are in the current directory that ExifTool is run in, or you must tell it to look in a directory. It is not going to scan your entire Mac for .mp3 or .m4a, nor is it limited to those two extensions. There were two .mp3 and one .m4a on my Desktop when I ran that command there.


Any designated audio file extension that had all, or any, missing metadata item would be reported.

Jan 17, 2022 5:52 PM in response to VikingOSX

Okay, this is getting there. Running that command returned a total of 5771 files that failed at least one condition in the batch. How can I get a string that returns files where multiple conditions are blank, instead of just one? (I tried flipping the "or"s to "and"s, which... returned a greater number of "failed condition" files, so that doesn't seem right.

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.

Looking for Files with Blank Metadata

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