Help me with Custom Fields

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

Moderators: Peke, Gurus

nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Re: Help me with Custom Fields

Post by nohitter151 »

Options > Appearance
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
bambinn
Posts: 2
Joined: Wed Jul 08, 2015 6:55 pm

Re:

Post by bambinn »

Guest wrote:Here is my attempt at modifying the script to use YYYYMMDD HH:MM format for improved sorting. I'm learning as I go, so it might be a little clumsy. It also borrows from other examples I found on the net. If the formatting disappears when I post this (as it does in my preview), I apologize. This would be saved as an alternate version of SelectedFilesStoreDate.vbs:

Code: Select all

'Modified 1/3/06 to save date in Custom3 as YYYYMMDD HH:MM format for improved sorting by date created

'To store the DateCreated of a file to field Custom3:
'    mySong.Custom3 = GetFileDateCreated(mySong.Path)

'To store the DateLastModified of a file to field Custom3:
'    mySong.Custom3 = GetFileDateLastModified(mySong.Path)

'Change the line with "CHANGE HERE IF YOU WANT" according to what you want (from the above possibilities)

Function pd(n, totalDigits) 
        if totalDigits > len(n) then 
            pd = String(totalDigits-len(n),"0") & n 
        else 
            pd = n 
        end if 
End Function 

Sub SelectedFilesStoreDate

  Dim mySongList
      Set mySongList = SDB.SelectedSongList

  If mySongList.Count = 0 Then
    Set mySongList = SDB.AllVisibleSongList
    If mySongList.Count = 0 Then
      SDB.MessageBox "Nothing selected!", mtError, Array(mbOK)
      Exit Sub
    End If
  End If

  Dim i, mySong, fd, fdt,fdtyyyymmd
  For i = 0 To mySongList.Count - 1
    Set mySong = mySongList.Item(i)
    fdt = GetFileDatecreated(mysong.path)   'CHANGE HERE IF YOU WANT
    if isdate(fdt) then
      fd = cDate(fdt)
      fdtyyyymmdd=Year(fd)&pd(month(fd),2)&pd(day(fd),2)&" "&formatdatetime(fd,vbShortTime)
    '  msgbox(fdtyyyymmdd)
      mySong.Custom3 = fdtyyyymmdd
      mySong.UpdateDB
    end if
  Next

End Sub



Function GetFileDateCreated(FilePath)

  Dim FSO
      Set FSO = CreateObject("Scripting.FileSystemObject")

  Dim File
      Set File = FSO.GetFile(FilePath)

  GetFileDateCreated = File.DateCreated

End Function



Function GetFileDateLastModified(FilePath)

  Dim FSO
      Set FSO = CreateObject("Scripting.FileSystemObject")

  Dim File
      Set File = FSO.GetFile(FilePath)

  GetFileDateLastModified = File.DateLastModified

End Function
EDIT Peke: Just made it look better.
I know it's a long time since this was posted, but i was wondering. Is it possible to make it look like YYYY.MM.DD instead of YYYYMMDD ?
Also is it possible to make Mediamonkey run this script on all new songs added?
Ostrich Egg
Posts: 2
Joined: Fri May 01, 2015 7:24 pm

Re: Re:

Post by Ostrich Egg »

bambinn wrote:
Guest wrote:Here is my attempt at modifying the script to use YYYYMMDD HH:MM format for improved sorting. I'm learning as I go, so it might be a little clumsy. It also borrows from other examples I found on the net. If the formatting disappears when I post this (as it does in my preview), I apologize. This would be saved as an alternate version of SelectedFilesStoreDate.vbs:

Code: Select all

'Modified 1/3/06 to save date in Custom3 as YYYYMMDD HH:MM format for improved sorting by date created

'To store the DateCreated of a file to field Custom3:
'    mySong.Custom3 = GetFileDateCreated(mySong.Path)

'To store the DateLastModified of a file to field Custom3:
'    mySong.Custom3 = GetFileDateLastModified(mySong.Path)

'Change the line with "CHANGE HERE IF YOU WANT" according to what you want (from the above possibilities)

Function pd(n, totalDigits) 
        if totalDigits > len(n) then 
            pd = String(totalDigits-len(n),"0") & n 
        else 
            pd = n 
        end if 
End Function 

Sub SelectedFilesStoreDate

  Dim mySongList
      Set mySongList = SDB.SelectedSongList

  If mySongList.Count = 0 Then
    Set mySongList = SDB.AllVisibleSongList
    If mySongList.Count = 0 Then
      SDB.MessageBox "Nothing selected!", mtError, Array(mbOK)
      Exit Sub
    End If
  End If

  Dim i, mySong, fd, fdt,fdtyyyymmd
  For i = 0 To mySongList.Count - 1
    Set mySong = mySongList.Item(i)
    fdt = GetFileDatecreated(mysong.path)   'CHANGE HERE IF YOU WANT
    if isdate(fdt) then
      fd = cDate(fdt)
      fdtyyyymmdd=Year(fd)&pd(month(fd),2)&pd(day(fd),2)&" "&formatdatetime(fd,vbShortTime)
    '  msgbox(fdtyyyymmdd)
      mySong.Custom3 = fdtyyyymmdd
      mySong.UpdateDB
    end if
  Next

End Sub



Function GetFileDateCreated(FilePath)

  Dim FSO
      Set FSO = CreateObject("Scripting.FileSystemObject")

  Dim File
      Set File = FSO.GetFile(FilePath)

  GetFileDateCreated = File.DateCreated

End Function



Function GetFileDateLastModified(FilePath)

  Dim FSO
      Set FSO = CreateObject("Scripting.FileSystemObject")

  Dim File
      Set File = FSO.GetFile(FilePath)

  GetFileDateLastModified = File.DateLastModified

End Function
EDIT Peke: Just made it look better.
I know it's a long time since this was posted, but i was wondering. Is it possible to make it look like YYYY.MM.DD instead of YYYYMMDD ?
Also is it possible to make Mediamonkey run this script on all new songs added?
Not sure about your first question, but see this post for your second one: http://www.mediamonkey.com/forum/viewto ... 85#p407310
zetsui
Posts: 6
Joined: Mon May 16, 2016 4:37 pm

Re: Help me with Custom Fields

Post by zetsui »

Man I really need this field for my spotify to mediamonkey workflow. Other than this one important issue Mediamonkey is 100x better than Itunes

http://imgur.com/a/qjNyj

i'm getting some vb errors. the funny version is that the old version of that script loads, but doesn't work correctly (ie doens't get the same date created dates as I would have off the files in Windows File explorer)
Post Reply