
[SelectedFilesStoreDate]
FileName=SelectedFilesStoreDate.vbs
ProcName=SelectedFilesStoreDate
Order=5
DisplayName=SelectedFilesStoreDate
Description=SelectedFilesStoreDate
Language=VBScript
ScriptType=0'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'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 Functioneljay05 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
'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 wrote:Thanks for the script! It's indispensable.![]()
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.
Users browsing this forum: Mizery_Made and 12 guests