Two scripts work together to assist in re-building playlists.
Playlist Names to Comments examines every MP3 and AAC track in the iTunes Library and copies the name of each playlist which that track appears in to that track's Comment field. Multiple playlists are accomodated. As you may know, Comment data is saved in the track's ID3 Tag, effectively allowing the MP3/AAC file to "remember" what iTunes playlist(s) it belongs to.
Restore Playlists is intended to run after using "Playlist Names to Comments". It examines the Comments field of every MP3/AAC track for the playlist name(s) stored there and assigns the track to those playlists. If a playlist no longer exists, the script will re-create it. If the track has already been assigned to a particular playlist, it will not be placed in that playlist again.
Read Me explains more.