Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

iTunes - how to create a playlist from a text file list of artists?

there is a DougScript called "Export selected song list" that lets you export e.g artist name from a playlist to a text file.

Is it possible to create a reverse Applescript that lets you create a playlist from a text file containing a list of artist names?

Essentially what I am trying to do is find an easy way to assign genre to all my artists in my iTunes library.

Of course to be able to do that one also needs an online source for artists sorted by genre and a way to export that list to text file. I am trying to find a way to do that.

Yahoo could be a source for the artists list but right now one cannot export the lists to a text file. I made the suggestion to make this available.
http://dir.yahoo.com/Entertainment/Music/Artists/ByGenre/Complete_List_ofGenres/?o=a

Maybe there is another way. I will ask in the iTunes forum.

Anyway, please let me know about the text file list to playlist problem.

iMac, 2 GHz Duo, 2 GB RAM, 256 MB VRAM, Mac OS X (10.5.7)

Posted on May 29, 2009 5:21 AM

Reply
Question marked as Top-ranking reply

Posted on May 29, 2009 9:59 AM

The following script should do the trick. The artist names need to be separated by returns and saved into a plain text file.

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
-- make a new iTunes playlist with artist names from a text file

set TheFile to (choose file with prompt "Select a plain text file containing artist names:")
tell application "Finder" to set TheName to (displayed name of TheFile) -- this will be the name of the new playlist
set MyArtists to paragraphs of (read TheFile) -- read artist names (separated by newlines) from the file

tell application "iTunes"
set NewPlaylist to (make new user playlist with properties {name:TheName})
repeat with AnItem in MyArtists -- get all tracks from each artist
set AnItem to (contents of AnItem)
if AnItem is not "" then try -- don't bother with empty names
set MyTracks to (location of file tracks of playlist "Music" whose artist is AnItem)
add MyTracks to NewPlaylist
on error errmess -- oopsie (not found, etc)
log errmess -- just log it
end try
end repeat
end tell
</pre>
5 replies
Sort By: 
Question marked as Top-ranking reply

May 29, 2009 9:59 AM in response to Detlef Schmitt

The following script should do the trick. The artist names need to be separated by returns and saved into a plain text file.

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
-- make a new iTunes playlist with artist names from a text file

set TheFile to (choose file with prompt "Select a plain text file containing artist names:")
tell application "Finder" to set TheName to (displayed name of TheFile) -- this will be the name of the new playlist
set MyArtists to paragraphs of (read TheFile) -- read artist names (separated by newlines) from the file

tell application "iTunes"
set NewPlaylist to (make new user playlist with properties {name:TheName})
repeat with AnItem in MyArtists -- get all tracks from each artist
set AnItem to (contents of AnItem)
if AnItem is not "" then try -- don't bother with empty names
set MyTracks to (location of file tracks of playlist "Music" whose artist is AnItem)
add MyTracks to NewPlaylist
on error errmess -- oopsie (not found, etc)
log errmess -- just log it
end try
end repeat
end tell
</pre>
Reply

May 29, 2009 6:29 PM in response to red_menace

thank you very much. This script works well.

This is how I tested it:
1. I created a playlist Y from a playlist X with the DougScript "One song from each artist in playlist"
2. Then I exported the artists from the playlist Y to a text file I called Z with the DougScript "Export selected song list"
3. Finally I imported the artists from the text file with your script. The script named the playlist Z.
Reply

May 31, 2009 5:59 AM in response to red_menace

red_menace, is it possible to modify the script so that the artist in the text file is not identical with the artist in the iTunes library but rather "begins with" the artist name?

It would be good if one could capture e.g. Bob Marley but also Bob Marley and The Wailers.

I suspect that the line: set AnItem to (contents of AnItem) needs to be changed, I just don't know how.

Your script works otherwise well. The script ignores small or capital letters. That is good. I tested it with artists for the genre Alternative from the following site. http://www.rockband.com/forums/archive/index.php/t-389.html
Now it pays that I cleaned up my library with beaTunes2.
Reply

May 31, 2009 7:51 AM in response to Detlef Schmitt

Sure - you can change the comparison part of the statement that gets the tracks from:

set MyTracks to (location of file tracks of playlist "Music" whose artist is AnItem)
-- to --
set MyTracks to (location of file tracks of playlist "Music" whose artist _begins with_ AnItem)
-- or --
set MyTracks to (location of file tracks of playlist "Music" whose artist contains AnItem)
Reply

iTunes - how to create a playlist from a text file list of artists?

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