Custom field update script

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

Moderators: Peke, Gurus

Paven
Posts: 37
Joined: Mon Jan 23, 2006 5:58 am
Location: Sweden

Custom field update script

Post by Paven »

Hello o hej
I have problem with assigning a value to my custom string.
basicly i got custom 3 as "Main Artist" i MM and would like i script that updates god "Album artist" or god "artist" on demand.
i sorting i use this field to sort artists to gether like John Lennon would have the beatles as Main artist.

thsi script supose to take album artist information or if not present artist information and stor it as "Main Artist" but i get an "Object Requierd" erro at line 15 colum 4

anyon with morexperiance that would help?

Code: Select all

'[CreateMainArtistName]
'FileName=CreateMainArtistName.vbs
'ProcName=CreateMainArtistName
'Order=1
'DisplayName=Create Main Artist
'Description=Copy AlbumArtistName or ArtistName to Main Artist
'Language=VBScript
'ScriptType=0

Sub CreateMainArtistName
  Dim list, itm, i
  Set list = SDB.CurrentSongList
  For i=0 To list.count-1
    Set itm = list.Item(i)
    If itm.Custom3 Is "" Then
      If itm.AlbumArtistName is "" Then
        itm.Custom3 = itm.ArtistName
      else
        itm.Custom3 = itm.AlbumArtistName
    end if
  end if
  Next
  list.UpdateAll
End Sub
ps i wish for an grouping function for artists in the futere.. making this scipt obsolete :)
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Is compares objects, you want to be comparing strings. Try this:

Code: Select all

'[CreateMainArtistName]
'FileName=CreateMainArtistName.vbs
'ProcName=CreateMainArtistName
'Order=1
'DisplayName=Create Main Artist
'Description=Copy AlbumArtistName or ArtistName to Main Artist
'Language=VBScript
'ScriptType=0

Sub CreateMainArtistName
  Dim list, itm, i
  Set list = SDB.CurrentSongList
  For i=0 To list.count-1
    Set itm = list.Item(i)
    If itm.Custom3 = "" Then
      If itm.AlbumArtistName = "" Then
        itm.Custom3 = itm.ArtistName
      else
        itm.Custom3 = itm.AlbumArtistName
    end if
  end if
  Next
  list.UpdateAll
End Sub
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Paven
Posts: 37
Joined: Mon Jan 23, 2006 5:58 am
Location: Sweden

Post by Paven »

Thanx it works now.
i am new to this language so i axpect everything to be more complex :)
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Yeah, almost everyday I use Uniface, VBScript and Delphi - I tend to get lots of compilation errors because I'm mixing my syntaxes! :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
JohnnyTaylor
Posts: 1
Joined: Mon Feb 01, 2021 4:28 pm

Re: Custom field update script

Post by JohnnyTaylor »

Hi, pavan, I want to say thank you for asking for the code, actually, I was also searching for the same. I am also new to this language and using this in a jumble solver code that is required for word games.
Post Reply