Help me with Custom Fields

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Help me with Custom Fields

Postby eljay05 » Fri Feb 03, 2006 10:05 am

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
eljay05
 

Postby Steegy » Fri Feb 03, 2006 10:23 am

Hello

Here's some code if you want "Date Created". If you want "Date Modified", you don't need this script because this functionality is already in MediaMonkey (right-click the column headers and check "Last Modified"):

Add the following lines to the Scripts.ini file (normally C:\Program Files\MediaMonkey\Scripts\Scripts.ini):
Code: Select all
[SelectedFilesStoreDate]
FileName=SelectedFilesStoreDate.vbs
ProcName=SelectedFilesStoreDate
Order=5
DisplayName=SelectedFilesStoreDate
Description=SelectedFilesStoreDate
Language=VBScript
ScriptType=0
This will add the script to MediaMonkey's Scripts menu: menu Tools > Scripts > SelectedFilesStoreDate

The script will save the date and time when the file was created to the field Custom3 for the selected files.

You can change the field where the information is written to (e.g. change Custom3 to DateAdded), and you can also save the DateLastModified instead.

Save the following code as a text file called SelectedFilesStoreDate.vbs in MediaMonkey's Scripts folder (the same folder where you edited the Scripts.ini file)

SelectedFilesStoreDate.vbs
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)   '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

Function GetFileDateLastModified(FilePath)
    Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
    Dim File : Set File = FSO.GetFile(FilePath)
    GetFileDateLastModified = File.DateLastModified
End Function


Cheers
Steegy
Last edited by Steegy on Thu Jun 14, 2007 8:42 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Steegy
 
Posts: 3448
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium

Re:

Postby eljay05 » Fri Feb 03, 2006 11:05 am

well nyways did what you said... but nuttin happens the Date Created Field I Made comes out Empty
eljay05
 

Postby Steegy » Fri Feb 03, 2006 11:27 am

Did you select songs and then started the script using menu Tools > Scripts > SelectedFilesStoreDate ?

Are your "Custom 3" fields still empty then? (I suppose you renamed them to "Date Created")

(Obviously the script only works on files that exist, that are accessible)
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Steegy
 
Posts: 3448
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium

Postby 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.
Franque
 

Postby 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.
Guest
 

sorting by "date created"

Postby 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!
Daniel
 

Re: Help me with Custom Fields

Postby 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
Guest
 

Re: Help me with Custom Fields

Postby 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
Another Drunk NPC
 
Posts: 1
Joined: Mon Feb 21, 2011 1:34 am

Re: Help me with Custom Fields

Postby 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)?
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?
nohitter151
 
Posts: 21582
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA

Re: Help me with Custom Fields

Postby 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?
HiFiGuy
 

How to sort tracks by Date Created in Windows Explorer?

Postby 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!
Last edited by Lowlander on Sat Nov 17, 2012 11:39 am, edited 2 times in total.
Reason: Merged with existing post
lordwasbinich
 
Posts: 1
Joined: Sat Nov 17, 2012 7:36 am


Return to Need Help with Addons?

Who is online

Users browsing this forum: Mizery_Made and 12 guests