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

Create a useful exported iTunes song list UNIX

The other day, I exported a playlist to text with iTunes in the hopes of making a quick CD Jacket. However, the playlist had a million fields, many of them utterly superfluous. So I figured I could just rid myself of the fields I didn't want with cut. Running into the Mac to UNIX line break problem with carriage returns (see robg's note), I solved it and did this all rather simply on my first try. But breaking out the old awk manual, I made a script to print the track name, artist, and time in correct form (iTunes saves it as the flat number of seconds, so it needs to be converted):

awk '{ gsub("\r", "\n"); print $0;}' Playlist.txt | \
awk 'BEGIN {FS="\t"} {if (NR == 1) printf "%s\t%s\t%s\n", $1, $2, $7; \
else if (NF != 0) printf "%s\t%s\t%i:%i\n", $1, $2, int($7/60), $7%60 }'

With a little work from TextEdit, it can be made to look pretty. I don't know if this will help anyone else, but it certainly saves me some time.

[robg adds: Mac to UNIX line breaks were covered in one of the earliest hints we ran here, so I've moved the explanation of the problem to the second part of this hint -- there's some new info there, so if you're interested in learning more about the differences, read the rest of the hint.]

Mac vs. UNIX line breaks: From time to time I run across a Mac text file that I want to do processing with awk, cut or paste in Unix. However, TextEdit and most mac programs generate Mac text files, which have new lines delimited by the Carriage Return character (character #0D, 'r'), while most unix commands are looking for a file with new lines marked by line feeds (#0A, 'n'). There are a number of ways of getting around this problem - one good site can be found at Indiana University's Knowledge Base. Here are some of the approaches they suggest:

tr:
tr '\r' '\n' < macfile.txt > unixfile.txt
awk:
awk '{ gsub("\r", "\n"); print $0;}' macfile.txt > unixfile.txt
perl:
perl -p -e 's/\r/\n/g'  < macfile.txt > unixfile.txt
The output, of course, doesn't have to be redirected at a file, it can be piped to anything, or just read on the screen.

    •    
  • Currently 1.50 / 5
  You rated: 2 / 5 (2 votes cast)
 
[9,288 views]  

Create a useful exported iTunes song list | 7 comments | Create New Account
Click here to return to the 'Create a useful exported iTunes song list' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a useful exported iTunes song list
Authored by: Deeeep on May 15, '03 02:40:36PM

Sorry to disillusion you, but in the library pane, control click on the header and select all the columns you want in your text file, then select all the files you want exported and select copy from the edit menu and go to textedit and select paste. Fields are tab separated and can easily be imported into excel....

Am I missing something in this hint?



[ Reply to This | # ]
Create a useful exported iTunes song list
Authored by: DougAdams on May 15, '03 05:53:26PM
Also: several AppleScript methods for exporting iTunes track and playlist data are on our Exporting Info pages.

Doug
Doug's AppleScripts for iTunes

---



[ Reply to This | # ]

Oops...
Authored by: XSage on May 16, '03 12:42:35AM
Looks like I made a minor mistake while copying.
The last line of that code block looks like: else if (NF != 0) printf "%s\t%s\t%i:%i\n", $1, $2, int($7/60), $7%60 }'

Instead, printf should have a %.2i in the last field so that it will always print 2 digits.

The new code block should look like

awk '{gsub("\r", "\n"); print $0;}' Playlist.txt | \
awk 'BEGIN {FS="\t"} {if (NR == 1) printf "%s\t%s\t%s\n", $1, $2, $7; \
else if (NF != 0) printf "%s\t%s\t%i:%.2i\n", $1, $2, int($7/60), $7%60}'

Hehe, sorry.



[ Reply to This | # ]
Oops...
Authored by: macubergeek on May 24, '03 08:43:04PM

If you export from iTunes you should substitute Library.txt not Playlist.txt and then it works fine.



[ Reply to This | # ]
Create a useful exported iTunes song list
Authored by: trevbuck on May 16, '03 04:05:59AM

hey sounds pretty complex to me...
I just pick a playlist ..then click Edit - View options - Untick everything except Artist , Album & time...

Copy & paste into text edit
thats it...

then just quickly use tab to clean it up a bit & print it.
It usually fits nicely on a CD cover.



[ Reply to This | # ]
Create a useful exported iTunes song list
Authored by: PeterDie on May 17, '03 01:15:07PM

I prepared two templates in Word, one for a complete album, one for a compilation of different artists.
I also simply alter the playlist in iTunes to song, (artist) and time, copy the whole lot, paste it in one of the templates.
The templates have automatic (outline) line-numbers (track-numbers), are aligned to fit an inlay and also have a square just the exact size of an inlay to assist in cutting the print to the correct size.
The difference is: complete album has header space for album/artist name, the compilation ones have not, but they have an extra column for artist in the body
Granted, it's more of a Word Hint than an OS-X hint, but this text handling sounds more like trying to invent a ball-point pen that also writes in zero gravity when you also simply can grab a pencil.



[ Reply to This | # ]
Use iTunes Catalog to create web catalogs
Authored by: andrewz on Nov 03, '03 10:31:19AM
You can use KavaSoft's new iTunes Catalog program to create web catalogs of your music, complete with cover art. It can create plain-text catalogs too if you're so inclined.

[ Reply to This | # ]