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

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Postby Steegy » Sat May 20, 2006 5:21 pm

Hello

There's no need to make a Scripts.ini entry.

How you use it:
a. Create a File TagsFromTagList.vbs in MediaMonkey\Scripts\Auto and paste the code.
b. Restart MM
So create the plain text file TagsFromTagList.vbs using the posted code and save it to MediaMonkey's Scripts\Auto folder.
Then restart MM and the script will automaticly start (and automaticly add a menu item).

Cheers
Steegy
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 onkel_enno » Mon May 22, 2006 12:37 am

Thanks Steegy :)

New Version:
Fixed: Screen didn't refresh
Fixed: ")" at the End of the Mask didn't work correctly
New: First Line of selected File is shown (for creating the Mask)
New: Mask-History

Code: Select all
Option Explicit

Sub OnStartUp
   if not (SDB.VersionHi >= 2 and SDB.VersionLo >= 5 and SDB.VersionRelease >= 3) then
      Dim Text
      Text = "'Auto-Tag from Taglist' needs MediaMonkey 2.5.3 or above." + chr(13)
      Text = Text & "Please Download the latest Version on http://www.MediaMonkey.com" + chr(13) + Chr(13)
      Text = Text & "Since MediaMonkey 2.5.3 isn't officially released, search the Forum for the latest Beta!"
      SDB.MessageBox Text, mtError, Array(mbOK)
   else
      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 if
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.INIFile.StringValue("TagsFromFileList", "LastFile")
   
   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) 'Song #
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%S") & Chr(13) 'Titel
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%A") & Chr(13) 'Interpret
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%R") & Chr(13) 'Album Interpret
   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) 'Jahr
   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) 'Komponist
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%P") & Chr(13) 'Ordner
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%F") & Chr(13) 'Dateiname
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%X")           'Überspringen
   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
     TagListLines = Count(TagListContent, Chr(13))
    
     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


Let me know if there are cases where it doesn't work.
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx
onkel_enno
 
Posts: 2139
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany

Postby Guest » Thu Jun 29, 2006 5:13 am

Anonymous wrote:Thanks for creating this, I appreciate it.

Unfortunately I'm getting an error. I created a file that had just the filenames as "1. songname". I selected the tracks and opened the dialog. It requested a filename, and after I selected the file, an error popped up:

Error #438 Object doesn't support this property or method: 'SDB.Tools.Mask2UFText'
File (script name) Line 55 Column 3


Any thoughts?
Guest
 

Postby trixmoto » Thu Jun 29, 2006 5:26 am

You probably don't have the latest version of MM. That would explain why the method could not be found.
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9711
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Postby sperk » Wed Nov 08, 2006 4:23 am

Is anyone still using this?

I get this error:
Number or lines in tag-list and track-list doesn't fit.

Here's the txt. file. It's 17 lines for 17 tracks.

1. Баллада о маленьком человеке
2. Марш футбольной команды "Медведей"
3. Вот это да! (песня Билла Сиггера)
4. Мистерия хиппи
5. Баллада о том, кто недожил (Прерванный полет)
6. Баллада об оружии
7. Баллада о манекенах
8. Баллада о Кокильоне
9. Баллада об уходе в рай
10. Баллада о времени
11. Баллада о борьбе
12. Баллада о ненависти
13. Баллада о коротком счастье
14. Баллада о вольных стрелках
15. Баллада о Кокильоне (версия 2)
16. Баллада о Любви
17. Баллада об оружии (версия 2)
sperk
 
Posts: 75
Joined: Wed Oct 11, 2006 1:52 pm

Postby trixmoto » Wed Nov 08, 2006 4:38 am

I've never seen this script, or used it. However, the best way to solve the problem is to find out more information! :)

Open the scriptfile in a text editor and find lines 148-149...
Code: Select all
     End If
     If Tracks.Count <> Int(TagListLines / MaskLines) Then

Between these lines insert the following line, to give you...
Code: Select all
     End If
     MsgBox "If "&Tracks.Count&" <> "&TagListLines&" / "&MaskLines&" Then"
     If Tracks.Count <> Int(TagListLines / MaskLines) Then

Then report back what the message says.
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9711
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Postby ResumeMan » Wed Nov 08, 2006 11:06 am

I use it all the time.

check to make sure you don't have a "return" at the end of the last line, or a blank line at the top. The whole text file needs to be 17 lines long.
ResumeMan
 
Posts: 33
Joined: Wed Feb 08, 2006 1:11 pm

Postby sperk » Wed Nov 08, 2006 2:19 pm

trixmoto wrote:I've never seen this script, or used it. However, the best way to solve the problem is to find out more information! :)

Open the scriptfile in a text editor and find lines 148-149...
Code: Select all
     End If
     If Tracks.Count <> Int(TagListLines / MaskLines) Then

Between these lines insert the following line, to give you...
Code: Select all
     End If
     MsgBox "If "&Tracks.Count&" <> "&TagListLines&" / "&MaskLines&" Then"
     If Tracks.Count <> Int(TagListLines / MaskLines) Then

Then report back what the message says.


I did that now I get:
If 17< > 9/1 Then (w/ an OK box, which I hit; now I get:)
Number or lines in tag-list and track-list doesn't fit.

I think it has something to do with the Russian letters.
When I save the .txt doc as ANSI the script works but I get only "?"s instead of letters.
When I save as unicode, unicode big endian or UTF-8 I get the above described problem.
sperk
 
Posts: 75
Joined: Wed Oct 11, 2006 1:52 pm

Postby Steegy » Wed Nov 08, 2006 6:38 pm

Are you editing that text file with Notepad? Or Write? Try both programs (open the file and save it again, and then run the script) because they handle/save text files a bit different.
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 sperk » Wed Nov 08, 2006 10:43 pm

Steegy wrote:Are you editing that text file with Notepad? Or Write? Try both programs (open the file and save it again, and then run the script) because they handle/save text files a bit different.


I'm using Notepad. I don't have Write, what is it?
thanks
sperk
 
Posts: 75
Joined: Wed Oct 11, 2006 1:52 pm

Postby Steegy » Thu Nov 09, 2006 5:50 am

Both NotePad and Write/Wordpad are text editors that are included in all Windows versions. It should be in your "Accessories" (Start > Programs > ...), but you can also launch it using the command "wordpad" or "write" from Start > Run (I'm not sure which one; I'm on Linux right now).
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 trixmoto » Thu Nov 09, 2006 5:59 am

The problem is probably that the textfile you are using is not using Chr(13) [the return key] as the end of line character. Chr(10) is the "new line" character which some use. Try opening the textfile in notepad and "redoing" the end of line characters.
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9711
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Postby sperk » Thu Nov 09, 2006 2:05 pm

trixmoto wrote:The problem is probably that the textfile you are using is not using Chr(13) [the return key] as the end of line character. Chr(10) is the "new line" character which some use. Try opening the textfile in notepad and "redoing" the end of line characters.


I'm not quite sure if I understand this but I went back and hit "enter" after each line but still it's the same.
After playing around with it I see that the problem is when saving a doc in unicode I get that error message( Number or lines in tag-list and track-list doesn't fit. ) even with English letters.
The problem is I can't save the Russian letters in ANSI because
they come out as all "?" marks. Basically, it's a catch 22 situation.
I tried wordpad but no help
:cry:
sperk
 
Posts: 75
Joined: Wed Oct 11, 2006 1:52 pm

Script fixed

Postby mjmesiti » Sat Jan 06, 2007 9:43 pm

Well I got it to work...

When it was comparing the mask with the number of lines in the file with the number of tracks selected, it was always 1 off. I did not have an extra CR at the bottom of my txt file. Added one also didn't work.

So I changed the following line:

TagListLines = Count(TagListContent, Chr(13))

to:

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

And it works like a charm. For example, if your text file has only the Title, seperated by CR LF, use the mask <Title>.

Let me know if anyone (or the original author) has another idea, but this is the one I came up with. With some minor testing, it seems to work well.

BTW, msdos CR LF is in fact the accepted file type, since it parses on CR (13) and then automatically skips the next character, which is a LF. If you don't have a LF, then it will always skips the first letter on each line. IMO, it would be best to auto parse CR LF, or CR or LF - or at least give you the option to choose in the dialog. Perhaps when I have time I will add this feature, then I will post it.

Here is the updated file:

Code: Select all
Option Explicit

Sub OnStartUp
   if not (SDB.VersionHi >= 2 and SDB.VersionLo >= 5 and SDB.VersionRelease >= 3) then
      Dim Text
      Text = "'Auto-Tag from Taglist' needs MediaMonkey 2.5.3 or above." + chr(13)
      Text = Text & "Please Download the latest Version on http://www.MediaMonkey.com" + chr(13) + Chr(13)
      Text = Text & "Since MediaMonkey 2.5.3 isn't officially released, search the Forum for the latest Beta!"
      SDB.MessageBox Text, mtError, Array(mbOK)
   else
      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 if
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.INIFile.StringValue("TagsFromFileList", "LastFile")
   
   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) 'Song #
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%S") & Chr(13) 'Titel
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%A") & Chr(13) 'Interpret
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%R") & Chr(13) 'Album Interpret
   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) 'Jahr
   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) 'Komponist
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%P") & Chr(13) 'Ordner
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%F") & Chr(13) 'Dateiname
   DropDownMask.Common.Hint = DropDownMask.Common.Hint & SDB.Tools.Mask2UFText("%X")           'Überspringen
   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
mjmesiti
 
Posts: 1
Joined: Mon Jun 19, 2006 9:19 pm

Postby ResumeMan » Sat Jan 06, 2007 10:50 pm

For what it' worth, I've never had that problem. Always worked when the lines match the files.

To the author, I wonder if it would be easy to modify the script so that the "Auto Tag from Tag-List" appears as a right-click context menu? It certainly works fine as-is, but that'd make this even a little more convenient!
ResumeMan
 
Posts: 33
Joined: Wed Feb 08, 2006 1:11 pm

PreviousNext

Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 11 guests