santanudas
Technical User
Hi guys,
I was trying to write a small bash script, which reads the iTunes’ Library.xml file and then print the name of the songs based on the “given” artist. In the end, I came up with something like this:
What is doing is: Reading the file > joining all the lines together > breaking the (putting a new line) after every </dict> (so that all the value between <dict> and <\dict> in a single line now) > grep the Artist name and the associated <Name> value (i.e. song) for every single occurrence.
It's working pretty well under Linux but not on the OS X version of BSD. Any idea why? Many thanks in advance for helping. Cheers!!
I was trying to write a small bash script, which reads the iTunes’ Library.xml file and then print the name of the songs based on the “given” artist. In the end, I came up with something like this:
Code:
cat ~/Music/iTunes/iTunes\ Music\ Library.xml | tr \\n ' ' | sed 's%</dict>%\n%g' | sed -e 's%<[/[:alnum:]]*>% %g' -e 's/[[:space:]][[:space:]]*/ /g' | grep 'Artist ABBA' | sed -e 's/.*\(file:[[:graph:]]*\).*/\1/g' -e 's%.*/%%g' | sed -e 's/%20/ /g' -e '\,$, s/\.[a-zA-Z0-9]*//' | sort
What is doing is: Reading the file > joining all the lines together > breaking the (putting a new line) after every </dict> (so that all the value between <dict> and <\dict> in a single line now) > grep the Artist name and the associated <Name> value (i.e. song) for every single occurrence.
It's working pretty well under Linux but not on the OS X version of BSD. Any idea why? Many thanks in advance for helping. Cheers!!