Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Find all EMI songs in the iTunes Library Apps
So everyone is all excited about Apple's new deal with EMI and DRM-less tracks. But the question is, do you really want to upgrade your songs at $0.30 per song? And how much will the "privilege" cost you? Unfortunately, iTunes is no help here because the copyright data is not an option for your smart playlists. Well, thanks to the modern wonder of metadata, we have a solution.

Here is a quick and easy Terminal command that will tell you what songs came from EMI:
mdfind -onlyin ~/Music/iTunes/iTunes Music 
"kMDItemCopyright == '*Emi*' kMDItemCodecs == '*protected*' "
For more metadata fun, try the mdls command. A good example is:
find . -name *.m4p -exec mdls -name "kMDItemCopyright" {} ;
Note that all the labels owned by EMI are probably going to have the same no-DRM deal, so you'll need to run this command for all those labels. Luckily Wikipedia has a list.

[robg adds:If you want to send the output to a text file, just append > ~/Desktop/myEMI.txt to the end of the above command. If your music is stored in a non-standard location, you'll also need to edit the path in the command.

In the above-linked PR piece, Apple promises that "iTunes will also offer customers a simple, one-click option to easily upgrade their entire library of all previously purchased EMI content to the higher quality DRM-free format for 30 cents a song." However, I'm not sure the process will show you your EMI-sourced songs first, or let you optionally upgrade only some of the songs (via checkboxes, perhaps?). In any event, if you're curious as to how many EMI tracks you presently own, this is a good way to find them in anticipation of the new deal's May start.]
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[22,656 views]  

Find all EMI songs in the iTunes Library | 24 comments | Create New Account
Click here to return to the 'Find all EMI songs in the iTunes Library' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 08:02:54AM
Neat! Here's an AppleScript version that locates your iTunes Music file and dumps the list to a text file on the desktop (note where there is a literal carriage return.)
try -- get the XML file, which contains the location of the Music folder
	set these_paths to do shell script "defaults read com.apple.iapps iTunesRecentDatabases"
	set the data_file to the text 19 thru ((the offset of "\")" in these_paths) - 1) of these_paths
	set musicFolder to ("/" & parse_xml_file((my replace_chars(data_file, "%20", " ")))) as string
end try

set rez to text_to_list((do shell script "mdfind -onlyin " & quoted form of musicFolder & "  \"kMDItemCopyright == '*Emi*' kMDItemCodecs == '*protected*' \""), "
") -- this is a carriage return!

set new_file to ((path to desktop) & "EMI files.txt") as string

try
	set fileRefr to (open for access new_file with write permission)
	write (rez as string) to fileRefr starting at eof
	close access fileRefr
on error errx number errNum from badObj
	try
		close access fileRefr
	end try
end try

on text_to_list(txt, delim)
	set saveD to AppleScript's text item delimiters
	try
		set AppleScript's text item delimiters to {delim}
		set theList to every text item of txt
	on error errStr number errNum
		set AppleScript's text item delimiters to saveD
		error errStr number errNum
	end try
	set AppleScript's text item delimiters to saveD
	return (theList)
end text_to_list

on replace_chars(txt, srch, repl)
	set AppleScript's text item delimiters to the srch
	set the item_list to every text item of txt
	set AppleScript's text item delimiters to the repl
	set txt to the item_list as string
	set AppleScript's text item delimiters to ""
	return txt
end replace_chars

to parse_xml_file(thePath)
	return (do shell script "grep '>Music Folder<' " & (quoted form of thePath) & " | cut -d/ -f5- | cut -d\\< -f1 | sed 's/%20/ /g'")
end parse_xml_file

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Find all EMI songs in the iTunes Library
Authored by: solipsism on Apr 06, '07 08:33:32AM

This is helpful. Thanks.

Is it possible to make an AppleScript that intereacts with iTunes by creating a playlist that will then list all of my EMI songs within iTunes so I don't have to bother with a text file?



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 08:46:34AM

It can be done, but will require a little work ;)

Also, as the original poster noted, all EMI tracks' metadata may not contain the text "EMI", so there are the other labels to incorporate, too.

If I have time I will post this at my site.

BTW, in case my initial "Neat!" comment is not enough, the original poster's idea is a very, very clever use of Spotlight scripting.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 09:07:24AM

It would be helpful to know the exact text to look for regarding the specific EMI labels. For instance, I fished some out with "Virgin" and "Blue Note", but nothing on "Chrysalis" or "Capitol". I have over 2000 iTunes Store purchases, but, of course, can't possibly have a representative track from each of EMI's subsidiary labels.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: kirkmc on Apr 06, '07 09:17:55AM

It doesn't work for me. It only returns two albums (one by Coldplay, and one by Daft Punk). I have 4 Coldplay albums purchased from the iTS, all of which are EMI recordings. I don't know how many others I have, but this isn't good enough.

Kirk

---
Read my blog: Kirkville -- http://www.mcelhearn.com
Musings, Opinion and Miscellanea, on Macs, iPods and more



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 09:29:45AM
Kirk, do this AppleScript
do shell script "mdls " & quoted form of POSIX path of ((choose file) as string) & " | open -f"
on the suspected files to see what pops up. Maybe "EMI" is not in the copyright metadata.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Find all EMI songs in the iTunes Library
Authored by: kirkmc on Apr 06, '07 10:48:03AM

No, it's Capitol.

So, for this to be useful, it will need to parse EMI and all their labels...

Kirk

---
Read my blog: Kirkville -- http://www.mcelhearn.com
Musings, Opinion and Miscellanea, on Macs, iPods and more



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 11:38:07AM
Kirk, didn't you read my previous post?

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Find all EMI songs in the iTunes Library
Authored by: macmath on Apr 08, '07 08:39:07AM
I appreciate the script and the hint and find it interesting even if we'll not need it for later.

Trying the code above to find the metadata, however, I find that not every song lists a line for 'kMDItemCopyright'. None of my 'Pink Floyd' does, for instance.

[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: adrianm on Apr 06, '07 09:36:53AM

I expect this will be redundant, as when the EMI upgrade offer is live, iTunes itself will tell you what you can upgrade, much like the 'complete the album' feature does now.

---
~/.sig: not found



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DavidRavenMoon on Apr 06, '07 10:23:20AM

Yep, that's exactly what they are going to do. So there's no need for this tip really.

---
G4/Digital Audio/1GHz, 1 GB, Mac OS X 10.4.9 • www.david-schwab.com • www.myspace/davidschwab • www.imanicoppola.net



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 12:10:07PM

Forewarned is forearmed. Plus, give us geeks a break.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: teece on Apr 06, '07 09:36:59AM

When posting a shell command, help the newbies out:

Either place paths in quotes, or escape spaces. Thus, it should be either:

mdfind -onlyin "~/Music/iTunes/iTunes Music"

OR
mdfind -onlyin ~/Music/iTunes/iTunes\ Music

Thanks
(this is especially important if the command could do something destructive).



[ Reply to This | # ]
FYI: It is case sensitive...
Authored by: tbolioli on Apr 06, '07 09:59:44AM

So for Columbia you need to search for COLUMBIA. Arista is Arista, and the list goes on. Some are oddly cased and others are not. A side not, apparently I have purchased from every label other than EMI... Oh well.
Tom



[ Reply to This | # ]
Work it in reverse
Authored by: DougAdams on Apr 06, '07 11:40:55AM

OK, well here's a project for someone: create a text file with a comprehensive list of all tracks' labels based on the copyright metadata tag.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: voiceofra on Apr 06, '07 02:14:53PM
find . -name *.m4p -exec mdls -name "kMDItemCopyright" {} \;
Note the escaped semi-colon...the parser seems to, er, escape the escapes...

[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: DougAdams on Apr 06, '07 02:38:30PM

Explain what this does. I ran it and got this:

find: ./.Spotlight-V100: Permission denied
find: ./.Trashes: Permission denied

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: extra88 on Apr 08, '07 12:34:58PM

It uses the unix command 'find' to look for protected files (*.m4p) in the current directory ( . ) and all sub-directories then executes the metadata list command to show the copyright info (-exec mdls -name "kMDItemCopyright") for all matches ( {} ). voiceofra merely pointed out that the original command in the article needed its semicolon escaped.

Results that include ./.Spotlight-V100 and ./.Trashes indicate you ran it at the root of a volume (where those directories reside). It says "permission denied" because only user 'root' has access to those directories. If the root of a volume is really the top level of where you keep your music, you can avoid seeing that message by running the command prepended by 'sudo.' Otherwise change to the correct directory before running the command.



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: Mac1985 on Apr 06, '07 06:51:19PM

Is this any different than doing a Find in the Finder and choosing "Copyright" from the Other... popup? The Finder seems to locate all of my EMI tracks pretty well with that method, or am I potentially missing some?



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: chabig on Apr 09, '07 05:57:29AM

Excellent point! I think it's exactly the same.



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: Swift on Apr 10, '07 12:34:46AM

Don't know why, but I couldn't get this to run. (A very new newbie I am).

And when I put my iPod in the next time for syncing, it stripped all the purchased tunes, because the computer was "deauthorized." I had to repair permissions -- a lot of files had an owner of 503 rather than 0, and the rw stuff was incomplete. It's all better now.

---
------------------------
Screenplays for Royalty
since 1749



[ Reply to This | # ]
Find all EMI songs in the iTunes Library
Authored by: amdg on Apr 10, '07 09:27:52AM

Apologies for the error in my original post. Apparently the "escaped" characters got clobbered. Make sure to include the backslashes. Here are the corrected commands:

mdfind -onlyin ~/Music/iTunes/iTunes\ Music "kMDItemCopyright == '*Emi*' kMDItemCodecs == '*protected*' "

find . -name *.m4p -exec mdls -name "kMDItemCopyright" {} \;



[ Reply to This | # ]
List of Labels
Authored by: amdg on Apr 10, '07 07:34:01PM

OK, I think this will work for everyone now. Check out the file with all the label names and the revised command at http://jescala.com/content/view/14/1/.



[ Reply to This | # ]
kMDItem... constants?
Authored by: fbitterlich on Apr 12, '07 07:35:57AM

Where can I find a list of all "kMDItem..." constants?



[ Reply to This | # ]