You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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

Playlist folders becoming Smart Playlist Folders

I too have encountered this strange bug where any imported playlist containing a folder will be converted to a smart playlist upon quitting Music and relaunching it.

https://discussions.apple.com/thread/250865442?answerId=251676705022#251676705022


The bug will created multiple nested smart play lists if you have multiple nested playlist folders as part of the import as well.


My Music Library.musiclibrary file has updated by iTunes.app and Music.app for over a decade now and so the meta data is very rich and I do not wish to see it disappear by starting fresh.


Until this bug is looked at, Music.app users who potentially import a playlist that contains playlist folders, may see this bug.


Here's a workaround, and have come up with the following steps and applescripts that work for my setup. If you wish to use the scripts it will help to know my setup.



Posted on Aug 29, 2020 9:21 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 29, 2020 9:32 PM

--part 2
		set thePlaylistName to name of thePlaylist as text
		set cutPosition to (offset of " - " in thePlaylistName) - 1
		set artistName to text 1 thru cutPosition of thePlaylistName
		set artistPlaylist to artistName --& " --"
		if not (exists folder playlist artistPlaylist) then
			make folder playlist with properties {name:artistPlaylist}
		end if
		
		set firstCharacter to the first character of the artistPlaylist
		
		set validCharacters to "abcdefghijklmnopqrstuvwxyz"
		repeat with tmpChar in characters of firstCharacter
			if validCharacters does not contain tmpChar then
				move folder playlist artistPlaylist to folder playlist "_Numeric"
			else
				ignoring case
					move folder playlist artistPlaylist to folder playlist firstCharacter
				end ignoring
			end if
		end repeat
		move user playlist thePlaylistName to folder playlist artistPlaylist
	end repeat
	display dialog "A total of " & orphanCount & " Playlists were moved into their respective Folder"
end tell


See how you go.

Similar questions

5 replies
Question marked as Top-ranking reply

Aug 29, 2020 9:32 PM in response to Hoondi

--part 2
		set thePlaylistName to name of thePlaylist as text
		set cutPosition to (offset of " - " in thePlaylistName) - 1
		set artistName to text 1 thru cutPosition of thePlaylistName
		set artistPlaylist to artistName --& " --"
		if not (exists folder playlist artistPlaylist) then
			make folder playlist with properties {name:artistPlaylist}
		end if
		
		set firstCharacter to the first character of the artistPlaylist
		
		set validCharacters to "abcdefghijklmnopqrstuvwxyz"
		repeat with tmpChar in characters of firstCharacter
			if validCharacters does not contain tmpChar then
				move folder playlist artistPlaylist to folder playlist "_Numeric"
			else
				ignoring case
					move folder playlist artistPlaylist to folder playlist firstCharacter
				end ignoring
			end if
		end repeat
		move user playlist thePlaylistName to folder playlist artistPlaylist
	end repeat
	display dialog "A total of " & orphanCount & " Playlists were moved into their respective Folder"
end tell


See how you go.

Aug 29, 2020 9:21 PM in response to Hoondi

Background

macOS 10.15.6

Mac mini 018 (6C@3.2GHz, 64GB)

Music.app 1.0.6.10


At the root level of Music.app I have a folder structure of playlist folders labelled A through to Z, and a _Numeric playlist folder at the very top.

eg:

_Numeric
A
B
C
..
Z

Under each root level playlist folder exists another playlist folder for each Artist.

eg:

A→ 
   ABBA
   ACDC
   Anna of the North

Under each Artist playlist folder will be a playlist representing an Album and the album's notation is <Artist_name> - <Album_name>

Note the single hyphen above, this whole importing of new playlists will look for and expect a double hyphen. I do this because it's a way for me to identify newly imported playlists.


I have lots of CDs, and over the years as it grew, I found the above setup to work best for me.


I store all my music on freeNAS, with means in Music's preferences under the Files tab, my path of Music media folder location is: "/Music/iTunes" as this is the SMB share name I've had since around the year 2004.


The two checkboxes under the Files tab:

Keep Music Media folder organised

Copy files to Music Media folder when adding to library

are unchecked.

I've ripped my CDs to folders many years ago and I did not want iTunes/Music to make copies or pull all my folder structure apart.



Aug 29, 2020 9:22 PM in response to Hoondi

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.

Aug 29, 2020 9:23 PM in response to Hoondi

Applescript 1.

-- No sanity! Use at your own risk
-- Script only works assumming there are no existing Playlists present
-- If you want create Playlists with existing Playlists, you'll need to add to the code to check for dupes

tell application "Music"
	activate
	set listOfAlbumNames to {}
	set itunesLibrary to a reference to (get view of front window)
	set totalNumberOfTracks to (count of every track in itunesLibrary)
	
	--display dialog "totalNumberOfTracks is " & totalNumberOfTracks & "."
	
	-- loop through each track, adding unique album names to the album array
	repeat with i from 1 to totalNumberOfTracks
		--try
		set currentTrack to (a reference to track i of itunesLibrary)
		set currentAlbumName to (currentTrack's album as string)
		set currentArtustName to (currentTrack's artist as string)
		
		-- I use a double hyphen here because I always export the Library to another Library
		-- and want to identify what has been imported
		-- This is also why this script assumes the Libray is void of existing Playlists
		-- Change to your preference
		set newPlaylistName to currentArtustName & " -- " & currentAlbumName
		
		if currentAlbumName is not "" then
			if listOfAlbumNames does not contain currentAlbumName then
				copy currentAlbumName to end of listOfAlbumNames
				set new_playlist to make user playlist with properties {name:newPlaylistName}
			end if
			--write the relevant tracks to the newly created playlist
			duplicate currentTrack to new_playlist
		end if
		--end try
	end repeat
end tell

Aug 29, 2020 9:27 PM in response to Hoondi

Applescript 2. (in two parts due to Apple's aggressive 5000 character limit) so paste the following together:

--part 1
tell application "Music"
	-- get Count of Playlists at root level by subtracting playlists that don't have a parent playlist
	
	set validplayList to 0
	set totalPlaylists to count (every playlist whose special kind is none)
	set thePlaylists to get every playlist whose special kind is none
	repeat with thePlaylist in thePlaylists
		try
			set parentFolder to name of parent of thePlaylist
			set validplayList to validplayList + 1
		on error
			exit repeat
		end try
	end repeat
	set orphanCount to (totalPlaylists - validplayList)
	if orphanCount is equal to 0 then
		display dialog "No Playlists are at the root level to be moved"
		error number -128
	end if
	
	--create playlist's Artist folder, move Artist folder to respective A-Z, move playlist	
	repeat (orphanCount) times
		set thePlaylists to get every playlist whose special kind is none
		repeat with thePlaylist in thePlaylists
			try
				set parentFolder to name of parent of thePlaylist
			on error
				exit repeat
			end try
		end repeat

Playlist folders becoming Smart Playlist Folders

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