Process
Please have a copy of your Music Library file and also your media. I'm not responsible for anything going wrong… yada yada… So with that out of the way.
Basically, to avoid the bug, you cannot import any exported playlist that references a playlist folder.
To achieve this I would.
1.
If you have new media files as part of the playlist import, move the media you wish to import into the same location as all your other media.
Launch Music.app with the Option key held down and create a new Library.
Call it anything you like as it's only temporary and will be eventually discarded.
Immediately go to Music Preferences → Files Tab and set the location to the Music Media folder.
mine is "smb://192.168.1.100/Music/iTunes/Music"
which becomes "/Music/iTunes" for me after pressing the OK button.
Just like your primary Library ensure the two checkboxes under the Files tab:
Keep Music Media folder organised
Copy files to Music Media folder when adding to library
are unchecked.
You now have an empty Library read to import your new media files.
File Menu → Add to Library...
At this open dialog window, navigate to your Music's Media folder where you have your new items.
As my setup at the file system is the same as what appears with my playlists, I would go to smb://192.168.1.100/Music/iTunes/Music/A and with the Command key held down, I would select all the new media folders and press the OK button.
Music.app will display a progress bar while it injects your new media.
Go to the "Songs" entry under "Library" down the left hand side of Music.app and you'll see all your newly imported song.
When creating new playlists, whatever columns you have shown here (being your principal playlist) will be used when creating new playlists. Command - J will bring up a panel to choose columns
I typically use:
Album
Artist
Track Number
Time
Rating
Plays
Last Played
Bit Rate
Sample Rate
For the following AppleScript to work, you must have the Album column visible and also chosen for sorting (ascending or descending doesn't matter).
Applescript 1.
Copy the code for the post after this one into a new AppleScript and run.
You'll see your new playlists appear for each album you've imported.
Note I use double hyphens as part of the newly created playlist name:
<Artist_name> -- <Album_name>
You can use whatever you like as your delimiter, just make sure that you change this in both scripts.
You might have to do some clean up around Album Artist and Album if you notice some playlists being created as fragments of an album.
This reason for this is:
set currentArtustName to (currentTrack's artist as string)
My ripping of CDs years ago did not populate "Album Artist" property and so I've used just the "Artist" property instead. If you endeavour to import CDs that have various artists, you might want to experiment with the script here to minimise your clean up.
Observe the result of the playlist creation and tend to them accordingly.
When ready, export the Library:
File → Library → Export Library…
(I save the file into the same temporary library area.. eg "A.xml" if I'm importing a bunch of playlists starting with the letter "A".
This will create an XML file ready to be imported into your primary Music Library.
Quit Music.app and relaunch it with Option key held down and navigate to your primary Music Library.
Remember, this process assumes that you have a top level of playlist folders (A-Z) and that you have no "orphan" playlists at the root level.
If you do, the following script will process these orphan playlists and move them.
Time to import:
File Menu → Library → Import Library…
navigate to the XML file you've just created and import.
Once imported, you'll see the new playlists appear below your playlist folder structure of A-Z.
This was the only way to get around the bug, i.e. import with no folder structure, and so now it's time to process the new playlists and move them into place.
If a new Artist exists, the script will also create a sub playlist folder for that Artist.
Copy the following into a new AppleScript windows:
Remember, this script is looking for your newly imported playlists to have a double hyphen as the delimiter:
Remember to change your delimiter be the same as the first script too.
<Artist_name> -- <Album_name>
Time to Run.
Applescript 2.
Copy the code of the 2nd post after this one into a new AppleScript and run.
This script is hacky, but it gets the job done.
It will take significant time to complete because it needs to iterate over every single song a few times in order determine what needs to be created and moved.
Edit to your liking, but I ran this overnight on a test library with > 500 playlists/20,000 songs and it completed as expected in about an hour.
--end.