Help me with Custom Fields

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Help me with Custom Fields

Re: Help me with Custom Fields

by zetsui » Mon Jun 06, 2016 11:38 pm

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)

Re: Re:

by Ostrich Egg » Wed Jul 29, 2015 7:52 pm

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

Re:

by bambinn » Wed Jul 08, 2015 6:59 pm

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?

Re: Help me with Custom Fields

by nohitter151 » Mon May 18, 2015 12:17 pm

Options > Appearance

Re: Help me with Custom Fields

by kah » Mon May 18, 2015 11:33 am

How do I rename the custom3 field? For some reason it was named Creation Date until two days ago then when I re-opened mediamonkey yesterday all my previous settings were gone (skin,field name and nodes) it was like I had reinstalled mediamonkey again but my library was intact, all my files were there and their creation date were there too. I have no idea what happened.

Re: Help me with Custom Fields

by Peke » Sat May 02, 2015 8:30 pm

Hi,
Nice, I'm glad that it is still possible to make it work.

Re:

by Ostrich Egg » Fri May 01, 2015 7:54 pm

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.
This is just great. Thanks a lot. Is there a way to make this script run on each file upon being imported to the library?

EDIT: Ok, I had never done MM scripting before, but I was able to get it working :D

The script below adds the file created date as Custom3 on track import.

Code: Select all

'Modified 5/1/15 to save date in Custom3 as YYYYMMDD HH:MM format on track import

'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)
Sub onStartup
  Script.RegisterEvent SDB, "OnTrackAdded", "AddFileStoreDate"
End Sub

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

Sub AddFileStoreDate(mysong)
	Dim fd, fdt, fdtyyyymmd
	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
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

How to sort tracks by Date Created in Windows Explorer?

by lordwasbinich » Sat Nov 17, 2012 7:52 am

Hi,

first, I'm german but i think there are more answers in english forum so sorry for my bad english.
I accidentally deleted all music in MediaMonkey. Thats not bad because I already have it on my PC so I just added it again to MM. The problem is that I sorted them by Date added to MM so that I have the newest tracks at the top of the list. But now all tracks are added today. My question is: Is there a possibility to sort the tracks by Date Created like in Windows Explorer?
I think there is one with scripts and so on but i don't have any antycipation [I don't know if this is right] how this works and what to do. I think it have something to do with these custom columns.

I'm happy about all answers. I think with my english knowledges and translators I'm able to understand everything :wink:

GOT SOLUTION! FOR EVERYONE HAVING THE SAME PROBLEM: http://www.mediamonkey.com/forum/viewtopic.php?p=35656 WORKS PERFECT!

Re: Help me with Custom Fields

by HiFiGuy » Tue Dec 27, 2011 1:56 pm

Hello--I used the VBS script that was posted by "Another Drunk NPC". First, thanks much for your work on this. My issue is that the dates don't sort accurately in Media Monkey. For example, files that were' created in 2010 will be followed by those created in 2011 and then back to 2010 again. Essentially, the sort function isn't working. Any thoughts how to correct this problem?

Re: Help me with Custom Fields

by nohitter151 » Mon Feb 21, 2011 11:00 am

Another Drunk NPC wrote:Thanks for the script! It's indispensable. :D
I added a line of code that sets the "Date Added To Library" time to the filetime. In my opinion this makes "Recently Added" playlists 100% more useful.
Cheers.
Are you aware that MM already keeps track of date added to library (the "Added" field)?

Re: Help me with Custom Fields

by Another Drunk NPC » Mon Feb 21, 2011 1:39 am

Thanks for the script! It's indispensable. :D
I added a line of code that sets the "Date Added To Library" time to the filetime. In my opinion this makes "Recently Added" playlists 100% more useful.
Cheers.

Code: Select all

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

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

'Change the line with "CHANGE HERE" according to what you want from the above possibilities


Sub SelectedFilesStoreDate
    Dim mySongList : Set mySongList = SDB.CurrentSongList

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

    Dim i, mySong
    For i = 0 To mySongList.Count - 1
        Set mySong = mySongList.Item(i)
        mySong.Custom3 = GetFileDateCreated(mySong.Path)
        mySong.DateAdded = GetFileDateCreated(mySong.Path)  
'CHANGE HERE
        mySong.UpdateDB
    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

Re: Help me with Custom Fields

by Guest » Fri Nov 16, 2007 5:38 am

eljay05 wrote:Help me with Custom Fields... i want to have a field named "Date Created" or "Date Modified" Field... which you know sorts my mp3 on the date which is created... thankx

sorting by "date created"

by Daniel » Mon Mar 26, 2007 5:18 pm

Hello!

I also think, that the "Date created" option is more important than "last modified" or "added to library". If you tag an old file, it suddenly appears at the top of your time-sorted library-list, what is really confusing. So I tried the new script and it really works fine, but unfortunately the results of the sorting procedure are not saved. When I restart MM, I have to sort everything again!

Apart from this problem, the script-solution seems not be very elegant anyway, because you have to run the scrpit everytime you add a new mp3-file to your hard-disk. Is it possible, to implement this sorting functionality into MM, so that it works instantly, just like in the windows explorer?

thx for your reply!

by Guest » Wed Jan 03, 2007 11:17 pm

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.

by Franque » Wed Oct 11, 2006 8:59 pm

I also think that the file creation date is much more important then the database addition date. This script is almost perfect. The only problem is that, being a text field, sorting doesn’t give you the correct order with this formatting (dd/mm/yyyy hh:mm:ss).

I backuped up the Data base e change the field to numeric and the sort function, in Access, worked fine. However, I couldn’t access data anymore from MediaMonkey, so I return to the backup file.

Wouldn’t the sort function give the correct order if the format were yyyy/mm/dd, instead? If so, how can this be done? (I suppose that this would be easier than change the type of the custom field, because that flexibility would have implications in other scripts, etc).

Thanks.

Top