Merge Playlists script
This Script will merge the songs of the selected playlist with all the songs of the children playlists and present them inside the MainTrackWindow
Known issues: Since this script uses the PlaylistByTitle function it wont work when 2 or more playlists exist using the same name. This will be fixed in a newer release
To Do: Option to select which playlists to merge even if those playlists dont bellong to the same branch of the MainTree.
Make code faster
Suggestions and/or corrections are welcome
Usage
Right click on a playlist and select "Merge Playlist with its children"
Code:
Save the following code as MergePlaylist.vbs inside the Script\Auto folder. Restart MM
EDIT
New Code Bellow
New Script: Merge Playlist with its children
New Script: Merge Playlist with its children
Last edited by psyXonova on Tue Jan 24, 2006 6:24 am, edited 2 times in total.
Ok, this fixes the situation where clicking on a different node, made the script keep adding tracks....
Code: Select all
'==========================================================================
' NAME: MergePlaylists.vbs
'
' AUTHOR: psyXonova
' DATE : 23/1/2006
'
' COMMENT: This script will merge selected playlist with its childen.
'
'==========================================================================
Set DicList = CreateObject("Scripting.Dictionary")
Sub OnStartup
SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_Tree,3,1
Dim miAddToFavouriteNodes
Set miAddToFavouriteNodes = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,0,0)
With miAddToFavouriteNodes
.Caption = "Merge Playlist with Children"
.OnClickFunc = "mergePlaylist"
.UseScript = Script.ScriptPath
.IconIndex = 18
End With
End Sub
Sub MergePlaylist(arg)
Set myNode = SDB.MainTree.CurrentNode
If myNode.NodeType <> 61 And myNode.NodeType <> 71 And mynode.NodeType <> 6 Then
MsgBox "Please select a playlist"
Else
If myNode.nodeType = 6 Then
MsgBox "You must select a playlist, and not the parent node"
Else
QSQL = "SELECT Playlists.IDPlaylist FROM Playlists WHERE Playlists.PlaylistName = '" & MyNode.Caption & "'" 'Like "& Node.Caption & " ORDER BY Playlist.ParentPlaylist"
Set Iter = SDB.Database.OpenSQL(QSQL)
i=0
While Not Iter.Eof
PlParent = Iter.ValueByIndex(0)
i=i+1
Iter.Next
Wend
If i>1 Then '2 or more playlists with the same name exist
MsgBox "Multiple playlists with the same name"
Else
Dim myPlaylist, list, MainWindow
Set myPlaylist = SDB.PlaylistByTitle(MyNode.Caption)
Set list = myPlaylist.ChildPlaylists
For i = 0 To list.Count -1
DicList.Add list.item(i).id, list.Item(i)
Next
Do While True
dicount = DicList.Count
arrayitems = DicList.Items
For j = 0 To DicList.Count - 1
Set myPlaylist = Arrayitems(j)
Set list = myPlaylist.ChildPlaylists
For i = 0 To list.Count -1
If Not DicList.Exists(list.Item(i).id) Then DicList.Add list.Item(i).id, list.Item(i)
Next
Next
If dicount => DicList.Count Then Exit Do
Loop
End If
arrayitems = DicList.Items
Set MainWindow = SDB.MainTracksWindow
For i = 0 To DicList.Count -1
Set myPlaylist = arrayitems(i)
AddID = MainWindow.CurrentAddingId
For j=0 To myPlaylist.Tracks.count -1
MainWindow.AddTrackEx myPlaylist.Tracks.Item(j), AddID
If SDB.MainTree.CurrentNode.caption <> myNode.caption Then Exit Sub
Next
Next
MainWindow.FinishAdding
End If
End If
End Sub
-
baker
-
baker
Actually, I just noticed that it seems to be mistakenly adding duplicate songs from the child in the place of other songs. For example, a child that contains 3 songs...
1. Beatles - Hard Day's Night
2. Doors - Light My Fire
3. Queen - Bicycle Race
...will transfer to the parent
1. Beatles - Hard Day's Night
2. Beatles - Hard Day's Night
3. Queen - Bicycle Race
Is it just me? I am using 2.52.951
1. Beatles - Hard Day's Night
2. Doors - Light My Fire
3. Queen - Bicycle Race
...will transfer to the parent
1. Beatles - Hard Day's Night
2. Beatles - Hard Day's Night
3. Queen - Bicycle Race
Is it just me? I am using 2.52.951
Fantastic Script!
I have used it to create Playlists using several Auto-Playlists. For Example....
I used it to make a radio station like list of 20 songs....
Parent- My 20 Songs (no songs here)
Children (Auto-Playlists)
1. List of 10 Random 5 Star songs
2. List of 7 Random 4 Star songs, not heard in at least a day
3. List of 3 Random 3 Star songs, ordered by not heard recently
I also ran into the repeating problem mentioned above.
It seems that each Child included will bring pair of duplicates to the Parent.
I think it can be fixed. With some slight modifications this script can do a ton to create some fanastic multi-blended playlists. Thank you and good luck, I'll be keeping an eye out!
EDIT: Also once the newly formed playlist plays past 12 it seems to begin deleting songs out of the playlist.
I have used it to create Playlists using several Auto-Playlists. For Example....
I used it to make a radio station like list of 20 songs....
Parent- My 20 Songs (no songs here)
Children (Auto-Playlists)
1. List of 10 Random 5 Star songs
2. List of 7 Random 4 Star songs, not heard in at least a day
3. List of 3 Random 3 Star songs, ordered by not heard recently
I also ran into the repeating problem mentioned above.
It seems that each Child included will bring pair of duplicates to the Parent.
I think it can be fixed. With some slight modifications this script can do a ton to create some fanastic multi-blended playlists. Thank you and good luck, I'll be keeping an eye out!
EDIT: Also once the newly formed playlist plays past 12 it seems to begin deleting songs out of the playlist.
Anyone know how to make this script *COPY* playlist entries from child playlists to the parent?
It seems that the current implementation *MOVES* static playlist tracks to the parent, which is bad when you merge a bunch of staticly made playlists into the parent (and thus losing the organization of the tracks in the childs).
It seems that the current implementation *MOVES* static playlist tracks to the parent, which is bad when you merge a bunch of staticly made playlists into the parent (and thus losing the organization of the tracks in the childs).
New script:
Last.FM Node Now with DJ Mode!
Last.fm + MediaMonkey = Scrobbler DJ!
Tag with MusicBrainz ~ Get Album Art!
Tweak the Monkey! ~ My Scripts Page

Last.fm + MediaMonkey = Scrobbler DJ!
Tag with MusicBrainz ~ Get Album Art!
Tweak the Monkey! ~ My Scripts Page
