Import tag info (track titles) from .txt files?

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Import tag info (track titles) from .txt files?

Re: Import tag info (track titles) from .txt files?

Post by gvmsia » Fri Jun 14, 2013 10:38 am

pls help, this is a sample of my Excel database that i converted to text. Can I know what to do next, to get it to be imported into MM columns columns "Custom 1", "Album", "Track#", "Title", "Artist"?

sample:
Code: Select all
FileNumber,Album,TrackNumber,Title,Artist
A0001,Everyday,1,I Did It,Dave Matthews Band
A0001,Everyday,2,When The World Ends,Dave Matthews Band
A0001,Everyday,3,Space Between,Dave Matthews Band
A0001,Everyday,4,Dreams Of Our Fathers,Dave Matthews Band
A0001,Everyday,5,So Right,Dave Matthews Band
A0001,Everyday,6,If I Had It All,Dave Matthews Band
A0001,Everyday,7,What You Are,Dave Matthews Band
A0001,Everyday,8,Angel,Dave Matthews Band
A0001,Everyday,9,Fool To Think,Dave Matthews Band
A0001,Everyday,10,Sleep To Dream Her,Dave Matthews Band
A0001,Everyday,11,Mother Father,Dave Matthews Band
A0001,Everyday,12,Everyday,Dave Matthews Band
A0002a,Woodstock 94 (Disc 1),1,Selling The Drama,Live
A0002a,Woodstock 94 (Disc 1),2,But Anyway,Blues Traveler
A0002a,Woodstock 94 (Disc 1),3,I'm The Only One,Melissa Etheridge
A0002a,Woodstock 94 (Disc 1),4,Feelin' Alright,Joe Cocker
A0002a,Woodstock 94 (Disc 1),5,(Stage Announcement),Woodstock 94
A0002a,Woodstock 94 (Disc 1),6,Dreams,Cranberries
A0002a,Woodstock 94 (Disc 1),7,Soup,Blind Melon
A0002a,Woodstock 94 (Disc 1),8,When I Come Around,Green Day
A0002a,Woodstock 94 (Disc 1),9,Shoop,Salt-N-Pepa
A0002a,Woodstock 94 (Disc 1),10,(Stage Announcement),Woodstock 94
A0002a,Woodstock 94 (Disc 1),11,Blood Sugar Sex Magik,Red Hot Chili Peppers
A0002a,Woodstock 94 (Disc 1),12,Porno For Pyros / Porno For Pyros,Porno For Pyros
A0002a,Woodstock 94 (Disc 1),13,Those Damned Blue-Collar Tweekers,Primus
A0002a,Woodstock 94 (Disc 1),14,Headed For Destruction,Jackyl
A0002a,Woodstock 94 (Disc 1),15,Draw The Line / F.I.N.E.,Aerosmith
A0002a,Woodstock 94 (Disc 1),16,(Stage Announcement),Woodstock 94
A0002a,Woodstock 94 (Disc 1),17,Happiness In Slavery,Nine Inch Nails
A0002b,Woodstock 94 (Disc 2),1,For Whom The Bell Tolls,Metallica
A0002b,Woodstock 94 (Disc 2),2,The Hunter,Paul Rodgers Featuring Slash Jason Bonham Neil S
A0002b,Woodstock 94 (Disc 2),3,Come Together,Neville Brothers
A0002b,Woodstock 94 (Disc 2),4,Run Baby Run,Sheryl Crow
A0002b,Woodstock 94 (Disc 2),5,Deja Vu,Crosby Stills & Nash
A0002b,Woodstock 94 (Disc 2),6,Dance M.F. Dance - Kiss Off,Violent Femmes
A0002b,Woodstock 94 (Disc 2),7,Shine,Collective Soul
A0002b,Woodstock 94 (Disc 2),8,Arrow,Candlebox
A0002b,Woodstock 94 (Disc 2),9,How I Could Just Kill A Man,Cypress Hill
A0002b,Woodstock 94 (Disc 2),10,Right Here Too Much,Rollins Band
A0002b,Woodstock 94 (Disc 2),11,Highway 61,Bob Dylan
A0002b,Woodstock 94 (Disc 2),12,Pearly Queen,Traffic
A0002b,Woodstock 94 (Disc 2),13,Biko,Peter Gabriel
A0003,Essential Eighties 1,1,Call Me,Blondie
A0003,Essential Eighties 1,2,Turning Japanese,Vapours
A0003,Essential Eighties 1,3,Bette Davis Eyes,Kim Carnes
A0003,Essential Eighties 1,4,Centerfold,J. Geils Band
A0003,Essential Eighties 1,5,Always Something There To Remind Me,Naked Eyes
A0003,Essential Eighties 1,6,Power Of Love,Huey Lewis & The News
A0003,Essential Eighties 1,7,Let's Go All The Way,Sly Fox
A0003,Essential Eighties 1,8,French Kissin' In The Usa,Deborah Harry
A0003,Essential Eighties 1,9,Don't Worry Be Happy,Bobby McFerrin
A0003,Essential Eighties 1,10,Down On The Border,Little River Band
A0003,Essential Eighties 1,11,Everywhere I Go,Qed
A0003,Essential Eighties 1,12,Love At First Sight,Kim Hart
A0003,Essential Eighties 1,13,Don't Forget Me (When I'm Gone),Glass Tiger
A0003,Essential Eighties 1,14,Man Overboard,Do-Re-Mi
A0003,Essential Eighties 1,15,Cry In Shame,Jonny Diesel & The Injectors
A0003,Essential Eighties 1,16,Somethings Gotton Hold Of My Heart,Marc Almond & Gene Pitney

Re: Import tag info (track titles) from .txt files?

Post by Eyal » Wed Apr 03, 2013 12:20 am

That's really strange that it doesn't appear in the menu. Adding the shortcut to this menu item means it's must be there and working. Otherwise the shortcut won't work. Are you sure you're looking in the TOOLS menu?

MM3 and MM4 handle the menus the same way.

:~)

Re: Import tag info (track titles) from .txt files?

Post by janderia » Mon Apr 01, 2013 10:32 pm

I've determined that the problem may reside in the menuitem options or something related. With my limited programing knowledge, that may not be correct but what I did find was that adding a shortcut option allows me to run the script without incident. My .mov files were re-tagged properly from my input file. The shortcut option was the only change I made. I'm still not seeing the menu item though. It would be nice to have it around so that I'm not relying on my memory to recall that I set CTRL-1 to run the script so if anyone has any ideas, please let me know. Could MM 4 handle the menuitems differently than MM3?

Here's the top portion of the script with my change...

Code: Select all
Option Explicit

Sub OnStartUp
      Dim MenuItem
      Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Tools, 1, -3)
         MenuItem.Caption = "Auto-Tag from Tag-List..."
         MenuItem.IconIndex = 26
         MenuItem.UseScript = Script.ScriptPath
         MenuItem.OnClickFunc = "TagFromTagList"
         MenuItem.Shortcut = "Ctrl+1"
      Set MenuItem = Nothing
End Sub


Thanks!

Re: Import tag info (track titles) from .txt files?

Post by janderia » Sat Mar 30, 2013 3:22 pm

Eyal wrote:In MM4 scripts are saved to the user folder. So it might be one of these folders:



I moved the .vbs file to C:\Users\<username>\AppData\Roaming\MediaMonkey\Scripts\Auto but I'm still not seeing anything in the Tools --> Scripts menu. I know that this script doesn't need an entry in scripts.ini but just to test things, I tried putting an entry in the scripts.ini anyway. There are two scripts.ini files on my computer, one is in the C:\Program Files (x86)\MediaMonkey\Scripts that was installed with Media Monkey. The other is in C:\Users\<username>\AppData\Roaming\MediaMonkey\Scripts\Auto and was installed with another script that seems to work ok (DiscogsAutoTagWeb.vbs). I added the ImportTagsFromText section after the DiscogsAutoTagWeb section.

Code: Select all
[ImportTagsFromText]
FileName=ImportTagsFromText.vbs
ProcName=TagFromTagList
Order=20
DisplayName=Import Tags From Text...
Description=Tags based on input from a text file
Language=VBScript
ScriptType=0


So at this point, I can start MM 4 and I do see a menu item with the scripts.ini section added. :)
The problem from here is that I get an error when I try to start the script by clicking on it from the menu. :(
This is the error I'm getting:

Code: Select all
Error #450 - Microsoft VBScript runtime error
Wrong number of arguments or invalid property assignment "TagFromTagList"
File: "C:\Users\<username>\AppData\Roaming\MediaMonkey\Scripts\ImportTagsFromText.vbs", Line: 1, Column: 0


I've since removed the extra section in scripts.ini and moved the script back to the Auto folder but unfortunately I'm still not able to see the script from the menu. I'm a systems type and not a developer so it wouldn't surprise me if its just something simple. Could there be something I'm missing?

Re: Import tag info (track titles) from .txt files?

Post by Eyal » Sat Mar 30, 2013 2:22 am

In MM4 scripts are saved to the user folder. So it might be one of these folders:

nohitter151 wrote:If you installed the script for a single user it would be at:

Windows 7 / Vista:
C:\Users\_your username_\AppData\Roaming\MediaMonkey\Scripts\Auto

Win XP:
C:\Documents and Settings\_your username_\Application Data\Roaming\MediaMonkey\Scripts\Auto

Re: Import Tags From Text File [MM3+]

Post by Janderia » Sat Mar 30, 2013 1:20 am

Eyal wrote:This is a complete working version of the script I have on my computer.

- Copy the code below to a TEXT file named ImportTagsFromText.vbs (or get the file from here)
- Save that file in Mediamonkey\Scripts\Auto folder.
- Restart MediaMonkey.

-> Select the tracks to tag, Run the script through Tools|Auto-Tag from Tag-List menu.

Code: Select all
'Forum: http://mediamonkey.com/forum/viewtopic.php?f=2&t=8882&st=0&sk=t&sd=a&start=15#p71332
'Modified by Eyal 2008-09-15, 2011-03-05 & 2011-07-04.
Option Explicit

Sub OnStartUp
      Dim MenuItem
      Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Tools, 1, -3)
         MenuItem.Caption = "Auto-Tag from Tag-List..."
         MenuItem.IconIndex = 26
         MenuItem.UseScript = Script.ScriptPath
         MenuItem.OnClickFunc = "TagFromTagList"
      Set MenuItem = Nothing
End Sub

Sub TagFromTagList(MenuItem)
   Dim Form, Label, Button, Dialog, DropDownMask
   Dim EditPath, DropDownMaskMask
   Dim FileSys, File
   Set FileSys = CreateObject("Scripting.FileSystemObject")
   Dim Content
   Dim a
   
   Set Form = SDB.UI.NewForm
   Form.Common.SetRect 0, 0, 310, 180
   Form.FormPosition = 4   ' Screen Center
   Form.BorderStyle = 3    ' Dialog
   Form.Caption = "Auto-Tag from Tag-List"
   
   Set Label = SDB.UI.NewLabel(Form)
   Label.Common.SetRect 10, 15, 280, 18
   Label.Caption = "Tag-List File:"
   
   Set EditPath = SDB.UI.NewEdit(Form)
   EditPath.Common.SetRect 10, 30, 280, 18
   EditPath.Text = SDB.SelectedSongList.Item(0).Path      'Mod by Eyal: use path of first selected track.
   
   Set Dialog = SDB.CommonDialog
   Dialog.InitDir = EditPath.Text
   Dialog.Filter = "*.txt|*.txt|*.csv|*.csv|*.*|*.*"
   Dialog.ShowOpen
   if Dialog.OK then
      EditPath.Text = Dialog.Filename
     
      'show first line of file
      Set File = FileSys.OpenTextFile(EditPath.Text, 1, False)
         Set Label = SDB.UI.NewLabel(Form)
        Label.Common.SetRect 10, 94, 280, 18
        Content   = File.ReadLine
         If Left(Content, 3) = "" Then Content = Mid(Content, 4)
         Label.Caption = Content
      Set File = Nothing
   end if
   Set Dialog = Nothing
   
   Set Label = SDB.UI.NewLabel(Form)
  Label.Common.SetRect 10, 54, 280, 18
  Label.Caption = "Mask:"
   
   Set DropDownMask = SDB.UI.NewDropDown(Form)
  DropDownMask.Common.SetRect 10, 69, 280, 18
   DropDownMask.Common.Hint = "<Tabulator>" & Chr(13)
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & "<Return>" & Chr(13)
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%T") & Chr(13) '<Track#>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%S") & Chr(13) '<Title>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%A") & Chr(13) '<Artist>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%R") & Chr(13) '<Album Artist>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%L") & Chr(13) '<Album>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%Y") & Chr(13) '<Year>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%G") & Chr(13) '<Genre>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%B") & Chr(13) '<Bitrate>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%M") & Chr(13) '<BPM>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%C") & Chr(13) '<Composer>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%P") & Chr(13) '<Folder>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%F") & Chr(13) '<Filename>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%X") & Chr(13) '<Skip>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%ZH") & Chr(13) '<Original Artist>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%ZD") & Chr(13) '<Comment>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%U") & Chr(13) '<Custom1>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%V") & Chr(13) '<Custom2>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%W") & Chr(13) '<Custom3>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%J") & Chr(13) '<Custom4>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%K")           '<Custom5>
   
     
   for a = 1 to 10
      Content = SDB.INIFile.StringValue("TagsFromFileList", "LastMask" & a)
      if Content <> "" then
         DropDownMask.AddItem(Content)
         if a = 1 then DropDownMask.Text = Content
      end if
   next

  Set Button = SDB.UI.NewButton( Form)
  Button.Caption = SDB.Localize("&Ok")
  Button.Common.SetRect 115, 110, 75, 25
  Button.ModalResult = 1
  Button.Default = True

  Set Button = SDB.UI.NewButton( Form)
  Button.Caption = SDB.Localize("&Cancel")
  Button.Common.SetRect 215, 110, 75, 25
  Button.ModalResult = 2
  Button.Cancel = True

  if Form.ShowModal = 1 then
     Dim Tracks, Track
     Dim FileListPos
     Dim Mask, MaskLines
     Dim TagListContent, TagListLines, LastFileListPos
     Dim intTemp
   
     Set Tracks = SDB.SelectedSongList
     
      for a = 1 to 10
         SDB.INIFile.DeleteKey "TagsFromFileList", "LastMask" & a
      next
      for a = 0 to DropDownMask.ItemCount
         if a = 0 then
            Content = DropDownMask.Text
         else
            Content = DropDownMask.ItemText(a - 1)
         end if
         if Content <> "" then SDB.INIFile.StringValue("TagsFromFileList", "LastMask" & (a + 1)) = Content
         
         'clear Duplicates in DropDownList
         for intTemp = a to DropDownMask.ItemCount - 1
            if DropDownMask.ItemText(intTemp) = Content then DropDownMask.DeleteItem(intTemp)
         next
      next
   
      if not SDB.Tools.FileSystem.FileExists(EditPath.Text) then
         SDB.MessageBox "File " & EditPath.Text & " not found!", mtError, Array(mbOK)
         Exit Sub
      end if
   
     Set File = FileSys.OpenTextFile(EditPath.Text, 1, False)
   
     Mask = SDB.Tools.UFText2Mask(DropDownMask.Text)
     Mask = Replace(Mask, "<Tabulator>", Chr(9))
      Mask = Replace(Mask, "<Return>", Chr(13))
     MaskLines = Count(Mask, Chr(13))
   
     TagListContent = File.ReadAll
     
    'modified by MJM 01-05-2007
    TagListLines = Count(TagListContent, Chr(13)) - 1
   
    'MsgBox "Int(TagListLines / MaskLines): " & Int(TagListLines / MaskLines)
    'MsgBox "TagListLines / MaskLines: " & TagListLines / MaskLines
   
     If (TagListLines / MaskLines) <> Int(TagListLines / MaskLines) Then
         if TagListLines <> (Int(TagListLines / MaskLines)*MaskLines + 1) then
            SDB.MessageBox "Number of Lines in Tag-List and Mask doesn't fit!", mtError, Array(mbOK)
          Exit Sub
         end if
     End If
     If Tracks.Count <> Int(TagListLines / MaskLines) Then
         SDB.MessageBox "Number of Lines in Tag-List and Track-List doesn't fit!", mtError, Array(mbOK)
       Exit Sub
     End If
   
     FileListPos = 0
     LastFileListPos = 0
     TagListContent = TagListContent + Chr(13)
     For intTemp = 1 To (TagListLines / MaskLines) 'soviele Tracks
         Set Track = Tracks.Item(intTemp - 1)
     
       For a = 1 To MaskLines
         FileListPos = InStr(FileListPos + 1, TagListContent, Chr(13))
       Next
       Content = Trim(Mid(TagListContent, LastFileListPos + 1, FileListPos - LastFileListPos-1))
         If Left(Content, 3) = "" Then Content = Mid(Content, 4)
         'necessary for ParseText:
         if InStr(Mask, "%A") then Track.ArtistName = ""
         if InStr(Mask, "%L") then Track.AlbumName = ""
         if InStr(Mask, "%R") then Track.AlbumArtistName = ""
         if InStr(Mask, "%G") then Track.Genre = ""

         Track.ParseText Content, Mask

       LastFileListPos = FileListPos + 1
         Set Track = Nothing
     Next
     
      'Refresh Screen
      SDB.MainTracksWindow.RemoveSelectedTracks
      for a = 0 to Tracks.Count - 1
         SDB.MainTracksWindow.AddTrack(Tracks.Item(a))
      next
      SDB.MainTracksWindow.FinishAdding
   
     If SDB.MessageBox("Correct?", mtConfirmation, Array(mbYes, mbNo)) = mrYes Then
       Tracks.UpdateAll
     Else
       SDB.MainTracksWindow.Refresh
     End If
  End if
End Sub

Function Count(Text, Seperator)
   Dim intTemp
   Count = 0
   intTemp = 1
   Do
     Count = Count + 1
     intTemp = InStr(intTemp + 1, Text, Seperator)
   Loop While intTemp > 0
End Function


Cheers!

Eyal :~)


I'm using MM 4.0.7.1511 and am trying to use this script but I'm not seeing the menu item under tools or tools --> scripts. I've tried saving the .vbs file with both notepad and with wordpad but neither seem to work. I've also tried removing the -1 from this line:

TagListLines = Count(TagListContent, Chr(13)) - 1

The version seems to be a couple years old so I'm wondering if it just won't work with the version of MM I have. Is anyone able to use it with ver 4.0.7.1511?

Thanks!

Re: Import tag info (track titles) from .txt files?

Post by Peke » Fri Mar 01, 2013 8:54 pm

If there is need for MMIP hosting I'll be glad to provide one.

Re: Import tag info (track titles) from .txt files?

Post by rozzah » Fri Mar 01, 2013 5:02 pm

I presume - you don't have to 'wrap' the numbered song name in a <Title>

e.g.
1. songname A
2. songname B
...

is
fine
it DOESN'T have to be <Title>1. songname A</Title>

I've tried both anyway.. no joy

I saved the latest vbs code and the above edits (last 2 posts) - I'm still getting the error
'Number of Lines in Tag-List and Track-List doesn't fit'

Can anyone confirm this working in latest Media Monkey 4.0.7.1511
I'm going try on an older Windows machine

To be honest I don't know why this is not a FEATURE - you should be able to paste from the web or into a dialouge box - the suggestion of a context menu for scripts extra would also be useful but want to getting it working first - I have Mozart x 40CD to tag !

Anyway - fair play to the original vbs writer

RoZZaH

Re: Import tag info (track titles) from .txt files?

Post by Nanya » Thu Oct 18, 2012 2:17 pm

Thanks for the awesome script, I use this all the time. I wanted it to support Unicode so I added a "-1" to lines 45 and 136. They should now read:

Code: Select all
Set File = FileSys.OpenTextFile(EditPath.Text, 1, False, -1)


Additionally, in order to prevent the script from continuing, it's necessary to add

Code: Select all
   Else
     Exit Sub


...between lines 51 & 52 so the result is:

Code: Select all
      Set File = Nothing
   Else
     Exit Sub
   End If
   

Import Tags From Text File [MM3+]

Post by Eyal » Fri Jun 08, 2012 3:25 am

This is a complete working version of the script I have on my computer.

- Copy the code below to a TEXT file named ImportTagsFromText.vbs (or get the file from here)
- Save that file in Mediamonkey\Scripts\Auto folder.
- Restart MediaMonkey.

-> Select the tracks to tag, Run the script through Tools|Auto-Tag from Tag-List menu.

Code: Select all
'Forum: http://mediamonkey.com/forum/viewtopic.php?f=2&t=8882&st=0&sk=t&sd=a&start=15#p71332
'Modified by Eyal 2008-09-15, 2011-03-05 & 2011-07-04.
Option Explicit

Sub OnStartUp
      Dim MenuItem
      Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Tools, 1, -3)
         MenuItem.Caption = "Auto-Tag from Tag-List..."
         MenuItem.IconIndex = 26
         MenuItem.UseScript = Script.ScriptPath
         MenuItem.OnClickFunc = "TagFromTagList"
      Set MenuItem = Nothing
End Sub

Sub TagFromTagList(MenuItem)
   Dim Form, Label, Button, Dialog, DropDownMask
   Dim EditPath, DropDownMaskMask
   Dim FileSys, File
   Set FileSys = CreateObject("Scripting.FileSystemObject")
   Dim Content
   Dim a
   
   Set Form = SDB.UI.NewForm
   Form.Common.SetRect 0, 0, 310, 180
   Form.FormPosition = 4   ' Screen Center
   Form.BorderStyle = 3    ' Dialog
   Form.Caption = "Auto-Tag from Tag-List"
   
   Set Label = SDB.UI.NewLabel(Form)
   Label.Common.SetRect 10, 15, 280, 18
   Label.Caption = "Tag-List File:"
   
   Set EditPath = SDB.UI.NewEdit(Form)
   EditPath.Common.SetRect 10, 30, 280, 18
   EditPath.Text = SDB.SelectedSongList.Item(0).Path      'Mod by Eyal: use path of first selected track.
   
   Set Dialog = SDB.CommonDialog
   Dialog.InitDir = EditPath.Text
   Dialog.Filter = "*.txt|*.txt|*.csv|*.csv|*.*|*.*"
   Dialog.ShowOpen
   if Dialog.OK then
      EditPath.Text = Dialog.Filename
     
      'show first line of file
      Set File = FileSys.OpenTextFile(EditPath.Text, 1, False)
         Set Label = SDB.UI.NewLabel(Form)
        Label.Common.SetRect 10, 94, 280, 18
        Content   = File.ReadLine
         If Left(Content, 3) = "" Then Content = Mid(Content, 4)
         Label.Caption = Content
      Set File = Nothing
   end if
   Set Dialog = Nothing
   
   Set Label = SDB.UI.NewLabel(Form)
  Label.Common.SetRect 10, 54, 280, 18
  Label.Caption = "Mask:"
   
   Set DropDownMask = SDB.UI.NewDropDown(Form)
  DropDownMask.Common.SetRect 10, 69, 280, 18
   DropDownMask.Common.Hint = "<Tabulator>" & Chr(13)
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & "<Return>" & Chr(13)
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%T") & Chr(13) '<Track#>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%S") & Chr(13) '<Title>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%A") & Chr(13) '<Artist>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%R") & Chr(13) '<Album Artist>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%L") & Chr(13) '<Album>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%Y") & Chr(13) '<Year>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%G") & Chr(13) '<Genre>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%B") & Chr(13) '<Bitrate>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%M") & Chr(13) '<BPM>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%C") & Chr(13) '<Composer>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%P") & Chr(13) '<Folder>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%F") & Chr(13) '<Filename>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%X") & Chr(13) '<Skip>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%ZH") & Chr(13) '<Original Artist>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%ZD") & Chr(13) '<Comment>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%U") & Chr(13) '<Custom1>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%V") & Chr(13) '<Custom2>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%W") & Chr(13) '<Custom3>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%J") & Chr(13) '<Custom4>
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%K")           '<Custom5>
   
     
   for a = 1 to 10
      Content = SDB.INIFile.StringValue("TagsFromFileList", "LastMask" & a)
      if Content <> "" then
         DropDownMask.AddItem(Content)
         if a = 1 then DropDownMask.Text = Content
      end if
   next

  Set Button = SDB.UI.NewButton( Form)
  Button.Caption = SDB.Localize("&Ok")
  Button.Common.SetRect 115, 110, 75, 25
  Button.ModalResult = 1
  Button.Default = True

  Set Button = SDB.UI.NewButton( Form)
  Button.Caption = SDB.Localize("&Cancel")
  Button.Common.SetRect 215, 110, 75, 25
  Button.ModalResult = 2
  Button.Cancel = True

  if Form.ShowModal = 1 then
     Dim Tracks, Track
     Dim FileListPos
     Dim Mask, MaskLines
     Dim TagListContent, TagListLines, LastFileListPos
     Dim intTemp
   
     Set Tracks = SDB.SelectedSongList
     
      for a = 1 to 10
         SDB.INIFile.DeleteKey "TagsFromFileList", "LastMask" & a
      next
      for a = 0 to DropDownMask.ItemCount
         if a = 0 then
            Content = DropDownMask.Text
         else
            Content = DropDownMask.ItemText(a - 1)
         end if
         if Content <> "" then SDB.INIFile.StringValue("TagsFromFileList", "LastMask" & (a + 1)) = Content
         
         'clear Duplicates in DropDownList
         for intTemp = a to DropDownMask.ItemCount - 1
            if DropDownMask.ItemText(intTemp) = Content then DropDownMask.DeleteItem(intTemp)
         next
      next
   
      if not SDB.Tools.FileSystem.FileExists(EditPath.Text) then
         SDB.MessageBox "File " & EditPath.Text & " not found!", mtError, Array(mbOK)
         Exit Sub
      end if
   
     Set File = FileSys.OpenTextFile(EditPath.Text, 1, False)
   
     Mask = SDB.Tools.UFText2Mask(DropDownMask.Text)
     Mask = Replace(Mask, "<Tabulator>", Chr(9))
      Mask = Replace(Mask, "<Return>", Chr(13))
     MaskLines = Count(Mask, Chr(13))
   
     TagListContent = File.ReadAll
     
    'modified by MJM 01-05-2007
    TagListLines = Count(TagListContent, Chr(13)) - 1
   
    'MsgBox "Int(TagListLines / MaskLines): " & Int(TagListLines / MaskLines)
    'MsgBox "TagListLines / MaskLines: " & TagListLines / MaskLines
   
     If (TagListLines / MaskLines) <> Int(TagListLines / MaskLines) Then
         if TagListLines <> (Int(TagListLines / MaskLines)*MaskLines + 1) then
            SDB.MessageBox "Number of Lines in Tag-List and Mask doesn't fit!", mtError, Array(mbOK)
          Exit Sub
         end if
     End If
     If Tracks.Count <> Int(TagListLines / MaskLines) Then
         SDB.MessageBox "Number of Lines in Tag-List and Track-List doesn't fit!", mtError, Array(mbOK)
       Exit Sub
     End If
   
     FileListPos = 0
     LastFileListPos = 0
     TagListContent = TagListContent + Chr(13)
     For intTemp = 1 To (TagListLines / MaskLines) 'soviele Tracks
         Set Track = Tracks.Item(intTemp - 1)
     
       For a = 1 To MaskLines
         FileListPos = InStr(FileListPos + 1, TagListContent, Chr(13))
       Next
       Content = Trim(Mid(TagListContent, LastFileListPos + 1, FileListPos - LastFileListPos-1))
         If Left(Content, 3) = "" Then Content = Mid(Content, 4)
         'necessary for ParseText:
         if InStr(Mask, "%A") then Track.ArtistName = ""
         if InStr(Mask, "%L") then Track.AlbumName = ""
         if InStr(Mask, "%R") then Track.AlbumArtistName = ""
         if InStr(Mask, "%G") then Track.Genre = ""

         Track.ParseText Content, Mask

       LastFileListPos = FileListPos + 1
         Set Track = Nothing
     Next
     
      'Refresh Screen
      SDB.MainTracksWindow.RemoveSelectedTracks
      for a = 0 to Tracks.Count - 1
         SDB.MainTracksWindow.AddTrack(Tracks.Item(a))
      next
      SDB.MainTracksWindow.FinishAdding
   
     If SDB.MessageBox("Correct?", mtConfirmation, Array(mbYes, mbNo)) = mrYes Then
       Tracks.UpdateAll
     Else
       SDB.MainTracksWindow.Refresh
     End If
  End if
End Sub

Function Count(Text, Seperator)
   Dim intTemp
   Count = 0
   intTemp = 1
   Do
     Count = Count + 1
     intTemp = InStr(intTemp + 1, Text, Seperator)
   Loop While intTemp > 0
End Function


Cheers!

Eyal :~)

Re: Import tag info (track titles) from .txt files?

Post by r4pr0r » Mon Jun 04, 2012 3:07 pm

Is there anywhere where this complete updated script is available?

Re: Import tag info (track titles) from .txt files?

Post by joshb » Fri Dec 30, 2011 3:57 pm

Please, how can this script be bound to a shortcut key, and/or added to the right-click context menu? I need to use this script on many, many folders of untagged .flacs!
This was asked by several earlier posters. I have tried a few things in the scripts.ini file, but I don't know scripting and I'm just fumbling around, and I get VBS runtime error 13 when I try to run it via the shortcut key.

Also, IMHO this script needs to be more visible. I've been looking for this functionality for YEARS and only found it yesterday, after hours of searching the forum. Can a final (with keyboard shortcuts) version be posted in a more prominent place?

thanks, Josh

Re: Import tag info (track titles) from .txt files?

Post by spencoid » Sat Apr 10, 2010 12:48 pm

I got a private message reply from trixmoto that solves this problem so I am sharing it here. There needs to be an exact match between the tag filed name and the entry in the txt file. It is apparently the field name in the sql database that is needed which can be different from the display name in MediaMonkey. To display the name of the album, you need to use "AlbumName" not album. Artist is ArtistName. Composer is "Author" The ones that displayed without problems were the ones that were named more obviously such as Genre for genre and Comment for comment. There is a list that shows the field names but to really understand how it works, you probably need to correlate the field name with the display name. I have not looked but this might be found in the mediamonkey.ini file?? http://www.mediamonkey.com/wiki/index.php/SDBSongData

Re: Import tag info (track titles) from .txt files?

Post by spencoid » Thu Apr 08, 2010 8:19 pm

i am trying to add txt tags to midi files. i wrote a program that creates .txt files for each entry in a tab delimited text file. i can make this more generally useful and available to others if another program like this is needed. i also have programs that dump text events from meta data in .mid files which is how i create the tabbed text file.

i am using the txt importer script but all i get imported is the title, none of the other tags. i read somewhere about needing to use the script name but can not find documentation on what the script names are for the common fields. here is an example of the text in one of my .txt files that does not work. i am using UTF8 encoding. might that be the problem?
Filename=D01028
Title=Cheek to Cheek, Isn't this a Lovely Day
Composer=Berlin
Artist=Carroll, Adam
Album=Duo-Art

Re: Import tag info (track titles) from .txt files?

Post by deeznudts » Fri Sep 25, 2009 9:49 am

Wow I've been looking for something like this for forever! Thank you so much resume man. If he can't do I don't know who can.

Top