auto tag edit at startup

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

auto tag edit at startup

Post by andy29075 » Sun Apr 15, 2007 8:20 pm

Hello all,
Please forgive me if this has been previously addressed; I don't hang out much in the script forum, and I couldn't find anything via searching.

In my impatience to wait for a non-alpha/beta MM3 w/podcast support, I've had to resort to Doppler and auto-sync playlists to set up my podcasts on my iPod. The problem is that Doppler hasn't fully implemented the ID3 tag renaming yet.

What I'd like to know: is there any way I can have/make/get a script that would either run at every startup of MM or constantly run in the background (like the File Monitor) that would tag any file in a particular folder with a given text string? I've got my podcasts in folders by subscription, but the ID3 tags aren't consistent within the subscription.

For example:
Doppler downloads a file (here, NPR news podcast) with the following tags:
artist = NPR
album artist = NPR_7AM_News
album = yeah_yeah
genre = Talk Radio

and I would like to have it and every other file in the folder in which it resides have their tags automatically converted to:
artist = NPR
album artist = NPR
album = NPR
genre = Podcast

In short, something that would edit ID3 tags of all files in a folder to a pre-specified value, and could preferably do a similar thing (with different predetermined values) for other folders containing other podcasts...

Thanks for any help you could offer to me!
-Andy J

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Apr 16, 2007 3:38 am

This is certainly possible via scripting on startup. You can also use the OnBeforeTracksMove and OnTrackAdded events to make sure that any new tracks in that folder are retagged, and any which are moved into that folder are retagged. Or you could have an OnTimer event which checks the folder every minute or so and retag the files.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Mon Apr 16, 2007 8:01 am

Thanks for the reply, trixmoto. BTW, I am a happy user of several of your scripts! About what you said, I have zero talent with programming; would implementing your suggestion require writing more than a few lines of code?
Thanks for your help!
-Andy J

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Apr 16, 2007 11:28 am

Well for the OnTrackAdded and OnBeforeTracksMove events you just need to create a .vbs file in the Scripts\Auto folder with this code in it...

Code: Select all

Folder = "\FOLDER\"

Sub onStartup
  Script.RegisterEvent SDB, "OnTrackAdded", "AddPodcast"
  Script.RegisterEvent SDB, "OnBeforeTracksMove","AddMultiple"
End Sub

Sub AddPodcast(track)
  If InStr(UCase(track.Path),UCase(Folder)) > 0 Then
    Call UpdateTrack(track)
  End If
End Sub

Sub AddMultiple(tracks,paths,move)
  For i = 0 To tracks.Count-1
    If InStr(UCase(paths.Item(i)),UCase(Folder)) > 0 Then
      Call UpdateTrack(tracks.Item(i))
    End If
  Next
End Sub

Sub UpdateTrack(track)
  track.ArtistName = "NPR"
  track.AlbumArtistName = "NPR"
  track.AlbumName = "NPR"
  track.Genre = "Podcast"
  track.UpdateArtist
  track.UpdateAlbum
  track.UpdateDB
End Sub
Obviously you'll need to change "\FOLDER\" to the relevant folder your podcasts are in, and you'll need to rescan that folder after restarting MM to retag the tracks.

N.B. Make sure you pick up the revised code! :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Mon Apr 16, 2007 3:04 pm

Trixmoto, THANKS! I really appreciate you taking the time to write out that code for me!

About the \FOLDER\ part, I can't seem to get the script to work... I have one folder with my podcasts in it (U:\My Podcasts), and within that are podcast specific folders (U:\My Podcasts\NPR or U:\My Podcasts\JPFO and so forth)...

What should I replace \FOLDER\ with? Should I use the direct path (U:\My Podcasts\NPR\) or something else?

Thanks for all your help!
-Andy J

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Apr 16, 2007 3:11 pm

No problem, I like writing code! :)

I can't remember if the drive letter is included in the path in both these situations so I'd recommend using "\My Podcasts\NPR\" as the Folder.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Mon Apr 16, 2007 4:16 pm

Thanks Trixmoto, that did it!

Now, how can I get it to work for multiple folders and multiple subscriptions? I'd like to be able to re-tag the files in different folders with different text strings. Is that possible?

Thanks!
-Andy

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Apr 16, 2007 4:20 pm

Are the tracks always in "U:\My Podcasts\<Name>"?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Mon Apr 16, 2007 4:22 pm

Man, you're fast!! Yes, the sub-folder name is the text string that I'd like to set the artist, album, and album artist tags to for all files within it. (That, plus adding "Podcast" as the genre tag.)

Thanks for your help!

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Tue Apr 17, 2007 3:21 am

Ok, try this...

Code: Select all

Folder = "\My Podcasts\"
Genre = "Podcast"

Sub onStartup
  Script.RegisterEvent SDB, "OnTrackAdded", "AddPodcast"
  Script.RegisterEvent SDB, "OnBeforeTracksMove","AddMultiple"
End Sub

Sub AddPodcast(track)
  p = InStr(UCase(track.Path),UCase(Folder))
  If p > 0 Then
    n = GetName(track.Path,p+Len(Folder))
    Call UpdateTrack(track,n)
  End If
End Sub

Sub AddMultiple(tracks,paths,move)
  For i = 0 To tracks.Count-1
    p = InStr(UCase(paths.Item(i)),UCase(Folder))
    If p > 0 Then
      n = GetName(paths.Item(i),p+Len(Folder))
      Call UpdateTrack(tracks.Item(i),n)
    End If
  Next
End Sub

Function GetName(path,pos)
  GetName = ""
  c = Mid(path,pos,1)
  While Not(c = "\")
    GetName = GetName&c
    pos = pos + 1
    c = Mid(path,pos,1)
  WEnd
End Function

Sub UpdateTrack(track,name)
  track.ArtistName = name
  track.AlbumArtistName = name
  track.AlbumName = name
  track.Genre = Genre
  track.UpdateArtist
  track.UpdateAlbum
  track.UpdateDB
End Sub
Last edited by trixmoto on Wed Apr 18, 2007 5:43 am, edited 2 times in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Tue Apr 17, 2007 6:54 am

Well, I tried it, and whenever I add new files to the library by pasting them into their folders, MM freezes on me... Any idea on how I can fix this? Is there a log that I can post that would help?
Thanks!
-Andy J

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Tue Apr 17, 2007 10:41 am

There was a typo in the GetName function. This has now been fixed so try recopying the code above.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Tue Apr 17, 2007 10:52 am

Thanks! Well, the good news is that it does retag them, but the bad news is that it cuts off the first letter on every single one of them... NPR becomes PR, JPFO becomes PFO, etc. Any idea on how to fix that?
Thanks for your help so far,
-Andy J

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Apr 18, 2007 5:44 am

Well I never said I could do maths! Should be sorted now. :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

andy29075
Posts: 11
Joined: Sun Apr 15, 2007 7:28 pm

Post by andy29075 » Wed Apr 18, 2007 6:29 am

Thanks Trixmoto, that fixed it!

I officially declare that you are friggin' awesome!

-Andy J

Post Reply