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


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 | # ]