Split Artist Title script update

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

KyleHx
Posts: 49
Joined: Fri Mar 13, 2015 11:09 am

Split Artist Title script update

Post by KyleHx »

I'd been using rhand's "Split Artist" script, from MM's addons (details below),
but it could only separate text that used a dash.
I had lots of files with slashes and tildes, so I thought I'd take a stab
at scripting, and this is the upshot.
With a text editor, you can just replace the entire text with my version.
==============================================================================

ORIGINAL INFO

http://www.mediamonkey.com/addons/brows ... ag-fixers/

Split Artist from 'Artist-Title' Title field 1.0

Some MP3 files, particularly those from 'Various Artists' collections,
unfortunately have the artist and title combined into the Title field,
("Beatles - Yes It Is") while the Artist field typically just has the
word "Various".
Running this script on selected files will leave you with
"Beatles" for Artist and "Yes It Is" for Title.

Note: this file is a text file and must be manually added as an addon.

By rhand
Submitted by rhand
Updated 14/11/2013
==============================================================================

KyleHx's Script version

' A simple script that splits the Artist from Title field of selected tracks
' if Title field actually holds "<artist> - <title>"
' Originally copied from SwapTitleArtist script from the MediaMonkey web site

Sub SplitArtistTitle
' Define variables
Dim list, itm, i, tmp

' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If

' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
artistTitle = itm.Title

' Look for '-' delimiter
dashPos = InStr(artistTitle, "-")
' If we have a '-' then split out Artist and Title
If dashPos > 0 Then
itm.ArtistName = Trim(Left(artistTitle,dashPos - 1))
itm.Title = Trim(Mid(artistTitle,dashPos + 1))
End If

' Look for '~' delimiter
dashPos = InStr(artistTitle, "~")
' If we have a '~' then split out Artist and Title
If dashPos > 0 Then
itm.ArtistName = Trim(Left(artistTitle,dashPos - 1))
itm.Title = Trim(Mid(artistTitle,dashPos + 1))
End If

' Look for '/' delimiter
dashPos = InStr(artistTitle, "/")
' If we have a '/' then split out Artist and Title
If dashPos > 0 Then
itm.ArtistName = Trim(Left(artistTitle,dashPos - 1))
itm.Title = Trim(Mid(artistTitle,dashPos + 1))
End If

' Update the changes in DB
itm.UpdateDB
list.UpdateAll

Next

End Sub
==============================================================================

ORIGINAL SCRIPT

' A simple script that splits the Artist from Title field of selected tracks
' if Title field actually holds "<artist> - <title>"
' Originally copied from SwapTitleArtist script from the MediaMonkey web site

Sub SplitArtistTitle
' Define variables
Dim list, itm, i, tmp

' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSongList
End If

' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)

' Look for '-' delimiter
artistTitle = itm.Title
dashPos = InStr(artistTitle, "-")
' If we have a '-' then split out Artist and Title
If dashPos > 0 Then
itm.ArtistName = Trim(Left(artistTitle,dashPos - 1))
itm.Title = Trim(Mid(artistTitle,dashPos + 1))

' Update the changes in DB
itm.UpdateDB
End If
Next
End Sub
==============================================================================