Script for several field modifications

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

W. Kyle White
Posts: 8
Joined: Sat Apr 30, 2005 1:32 pm

Script for several field modifications

Post by W. Kyle White » Sat Jul 30, 2005 10:07 am

I made this a while ago and planned on cleaning it up before submitting it, but if I wait until then I'll never submit it.

Here's some additions which can be made to the .ini *YOU MAY NEED TO CHANGE THE ORDER NUMBERS SO THEY DON'T CONFLICT WITH YOUR OWN .INI

Code: Select all


[BackupClassificationToCustom3]
FileName=Custom Scripts.vbs
ProcName=BackupClassificationToCustom3
Order=6
DisplayName=Change the Classification String
Description=Change the Classification String
Language=VBScript
ScriptType=0

[AddCategoryToCustom1]
FileName=Custom Scripts.vbs
ProcName=AddCategoryToCustom1
Order=8
DisplayName=Add a Category
Description=Add a Category
Language=VBScript 
ScriptType=0 

[RemoveCategoryFromCustom1] 
FileName=Custom Scripts.vbs
ProcName=RemoveCategoryFromCustom1
Order=12
DisplayName=Remove a Category
Description=Remove a Category
Language=VBScript 
ScriptType=0 

[ReplaceStringInField]
FileName=Custom Scripts.vbs
ProcName=ReplaceStringInField
order=48
DisplayName=*Replace a String in a Field
Description=Replace a String in a Field
Language=VBScript
ScriptType=0

[ModifyField]
FileName=Custom Scripts.vbs
ProcName=ModifyField
Order=49
DisplayName=*Modify a field
Description=Modify a field
Language=VBScript
ScriptType=0

[SwapFields]
FileName=Custom Scripts.vbs
ProcName=SwapFields
Order=50
DisplayName=*Swap Two Fields
Description=Swap Two Fields
Language=VBScript
ScriptType=0

[AddValueToTrackNum] 
FileName=Custom Scripts.vbs
ProcName=AddValueToTrackNum
Order=99
DisplayName=Add a value to the track#
Description=Add a value to the track#
Language=VBScript 
ScriptType=0 
BackupClassificationToCustom3 will turn a classification (which is stored as a nominal value) into it's string value and place that in the custom3 field. When it asks for a classification to backup you can enter: tempo, mood, occasion, or quality *update, now this can be done with the modify field command as well. WKW

AddCategoryToCustom1 will take a string and add it to the end of custom1 including proper comma separation. With winamp I used the comment field to store categories for my music, but with MM I stick them in custom1 so I can search on keywords. It will not add a string if the string already exists in custom1. Just type in the string to add without any commas.

RemoveCategoryFromCustom1 will remove a comma separated string while maintaining the rest of the categories. Just type in the string to remove without any commas.

ReplaceStringInField will request a field (given below), a string to replace, and the string to replace it with. White space is included in the strings

ModifyField requests a field and then a new value for the field. The difference is that it overwrites the entire field and it can take other fields as arguments (in <>). For example, enter the field "TITLE" and then replace it with "<TRACK#>. <TITLE>" and you'll end up with a title such as "11. Free Falling".

SwapFields requests 2 fields and then swaps the contents.

AddValueToTrackNum requests a numeric value and then adds that to the track. I use this mainly for multi-disc albums so I can either add 100 & 200 to the track numbers or just add a number to the second disc's tracks.


Here's the fields
ARTIST
TRACK#
TITLE
ALBUM
ALBUMARTIST
CUSTOM1
CUSTOM2
CUSTOM3
GENRE
COMMENT *added 11/10
PATH *added 2/1/8, thx Roger. WKW
TEMPO *added 2/2/8. WKW
MOOD *added 2/2/8. WKW
OCCASION *added 2/2/8. WKW
QUALITY *added 2/2/8. WKW



Here's the messy code for these functions.

Code: Select all

Dim ClassificationDict, FieldDict

Set ClassificationDict = CreateObject("Scripting.Dictionary") 
With ClassificationDict 
   .Add "TEMPO", "1" 
   .Add "MOOD", "2" 
   .Add "OCCASION", "3" 
   .Add "QUALITY", "4" 
End With 
   

Set FieldDict = CreateObject("Scripting.Dictionary")
With FieldDict
  .Add "<ARTIST>", "ArtistName"
  .Add "<TRACK#>", "TrackOrder"
  .Add "<TITLE>", "Title"
  .Add "<ALBUM>", "AlbumName"
  .Add "<ALBUMARTIST>", "AlbumArtistName"
  .Add "<CUSTOM1>", "Custom1"
  .Add "<CUSTOM2>", "Custom2"
  .Add "<CUSTOM3>", "Custom3"
  .Add "<GENRE>", "Genre"
  .Add "<PATH>", "Path"  'comment field added 2/2/8, thanks again Roger. WKW
  .Add "<COMMENT>", "Comment"      'comment field added by request, Thanx Rogerr
  .Add "<TEMPO>", "Tempo"
  .Add "<MOOD>", "Mood"
  .Add "<OCCASION>", "Occasion"
  .Add "<QUALITY>", "Quality"
'last four were added 2/2/8 and not been checked. Due to new access methods in MM. WKW


End With   



Function Cond(test, a, b)   ' Returns a if test evaluates to true, b otherwise
	If test Then
		Cond = a
	Else
		Cond = b
	End If
End Function


Function CurrentVersion
	CurrentVersion = 100 * SDB.VersionHi + SDB.VersionLo
End Function

Function SkinnedInputBox(text, caption, input) 

   Dim Form, Label, Edt, btnOk, btnCancel, modalResult 

   ' Create the window to be shown 
   Set Form = SDB.UI.NewForm 
   Form.Common.SetRect 100, 100, 360, 130 
   Form.BorderStyle  = 2   ' Resizable 
   Form.FormPosition = 4   ' Screen Center 
   Form.SavePositionName = "Remember position" 
   Form.Caption = caption 
      
   ' Create a button that closes the window 
   Set Label = SDB.UI.NewLabel(Form) 
   Label.Caption = text 
   Label.Common.Left = 5 
   Label.Common.Top = 10 
     
   Set Edt = SDB.UI.NewEdit(Form) 
   Edt.Common.Left = Label.Common.Left 
   Edt.Common.Top = Label.Common.Top + Label.Common.Height + 5 
   Edt.Common.Width = Form.Common.Width - 20 
   Edt.Common.ControlName = "Edit1" 
   Edt.Common.Anchors = 1+2+4 'Left+Top+Right 
   Edt.Text = Input 
       
   ' Create a button that closes the window 
   Set BtnOk = SDB.UI.NewButton(Form) 
   BtnOk.Caption = "&OK" 
   BtnOk.Common.Top = Edt.Common.Top + Edt.Common.Height + 10 
   BtnOk.Common.Hint = "OK" 
   BtnOk.Common.Anchors = 4   ' Right 
   BtnOk.UseScript = Script.ScriptPath 
   If currentVersion() >= 204 Then BtnOk.Default = True
   BtnOk.ModalResult = 1 
    
   Set BtnCancel = SDB.UI.NewButton(Form) 
   BtnCancel.Caption = "&Cancel" 
   BtnCancel.Common.Left = Form.Common.Width - BtnCancel.Common.Width - 15 
   BtnOK.Common.Left = BtnCancel.Common.Left - BtnOK.Common.Width - 10 
   BtnCancel.Common.Top = BtnOK.Common.Top 
   BtnCancel.Common.Hint = "Cancel" 
   BtnCancel.Common.Anchors = 4   ' Right 
   BtnCancel.UseScript = Script.ScriptPath 
   If currentVersion() >= 204 Then BtnCancel.Cancel = True
   BtnCancel.ModalResult = 2 
       
   modalResult = Form.showModal 
       
   SkinnedInputBox = Cond(modalResult=1, Edt.Text, "") 
       
End Function 


'-------------------------------------------------------------------------
'These functions are building blocks to create and execute scripts



Function kwToCommand(statement)
'replaces data fields with proper references for execution
  Dim i, fields
  fields = FieldDict.Keys
	For i = 0 To FieldDict.Count - 1
		statement = Replace(statement, fields(i), "itm."&FieldDict.Item(fields(i))) 
	Next
  kwToCommand = statement
End Function



Function kwToStringStatement(statement)
  Dim i, fields
  fields = FieldDict.Keys
	For i = 0 To FieldDict.Count - 1
		statement = Replace(statement, fields(i), Chr(34)&"&itm."&FieldDict.Item(fields(i))&"&"&Chr(34) ) 
	Next
  kwToStringStatement = statement
End Function



Function kwToString(s)
  kwToString = Chr(34)&s&Chr(34)
End Function
Function kwToField(s)
  kwToField = "<"&s&">"
End Function



Function kwExecuteStatement(statement)
'run a script on each selected track
  Dim list, itm, i
  
'  If (SDB.MessageBox( "Execute: "&Chr(34)&statement&Chr(34)&"?", mtConfirmation, Array(mbYes, mbNo)) = mrNo) Then Exit Function 

	
	
  Set list = SDB.SelectedSongList 
  If list.count=0 Then 
  Set list = SDB.AllVisibleSongList 
  End If  

  If(Replace(UCase(statement),"UPDATEDB","") = UCase(statement)) Then statement = statement & ":itm.UpdateDB"

' Process all selected tracks
  For i=0 To list.count-1
    Set itm = list.Item(i)
    Execute statement
  Next
  
End Function


'---------------------------------------------------------------
'These are generic functions for manipulation of data
'The "kwCommand" functions build a "script" to be executed
'on each selected entry and the following subroutines are
'the interfaces to build those commands from user input



Function kwCommandSwapFields(field1, field2)
  Dim s
    ' Build the statement to swap fields

    s =     "tmp = field1:"
    s = s & "field1 = field2:"
    s = s & "field2 = tmp:"
    s = s & "itm.UpdateDB"
    s = Replace(s, "field1", field1)
    s = Replace(s, "field2", field2)
    s = kwToCommand(s)

    kwCommandSwapFields = s

End Function
Sub SwapFields
  Dim field1, field2

  field1 = UCase(SkinnedInputBox("Enter field1", "", "ALBUM")) 
   if (field1 = "") then 
      Exit Sub 
   End If 

  field2 = UCase(SkinnedInputBox("Enter field2", "", "ARTIST")) 
   if (field2 = "") then 
      Exit Sub 
   End If
  kwExecuteStatement kwCommandSwapFields(kwToField(field1), kwToField(field2))
End Sub



Function kwCommandModifyField(field, s)
	s = kwToStringStatement(s)
  s = field&" = "&kwToString(s)&":itm.UpdateDB"
  s = kwToCommand(s)
  kwCommandModifyField = s
End Function
Sub ModifyField
  Dim s, field

  field = UCase(SkinnedInputBox("Enter field", "", "TITLE")) 
   if (field = "") then 
      Exit Sub 
   End If 

  s = UCase(SkinnedInputBox("Enter new field", "", "<TITLE>")) 
   if (s = "") then 
      Exit Sub 
   End If 

  kwExecuteStatement kwCommandModifyField(kwToField(field), s) 
  

End Sub


Sub AddCategoryToCustom1
  ' Define variables
  Dim category, s

  category = Trim(SkinnedInputBox("Enter the Category to add", "Add Category", ""))
    if (category = "") then
      Exit Sub
    End If
	
  s = s & "  If(itm.Custom1 = '''') Then:"
  s = s & "    itm.Custom1 = category:"
  s = s & "    itm.UpdateDB:"
  s = s & "  Else If(InStr(LCase(itm.Custom1), LCase(category)) = 0) Then:"
  s = s & "    itm.Custom1 = itm.Custom1 & '', '' & category:"
  s = s & "    itm.UpdateDB:"
  s = s & "  End If"
  s = Replace(s, "''", Chr(34))
  kwExecuteStatement Replace(s, "category", kwToString(category))
  
End Sub


Function kwCommandReplaceStringInField(field, s, s2)
  kwCommandReplaceStringInField = kwToCommand(  field&" = Replace("&field&", "&kwToString(s)&", "&kwToString(s2)&")" )
End Function
Sub ReplaceStringInField
  Dim s, s2, field

  field = UCase(SkinnedInputBox("Enter field", "", "TITLE")) 
   if (field = "") then 
      Exit Sub 
   End If 

  s = SkinnedInputBox("Enter string to replace", "", "")
   if (s = "") then 
      Exit Sub 
   End If 

  s2 = SkinnedInputBox("Enter new string", "", "")
   if (s = "") then 
      Exit Sub 
   End If 

  kwExecuteStatement kwCommandReplaceStringInField(kwToField(field), s, s2)
End Sub



Sub RemoveCategoryFromCustom1
  ' Define variables
  Dim category, s

  category = Trim(SkinnedInputBox("Enter the Category to remove", "Remove Category", "Blah"&Chr(34)))
    if (category = "") then
      Exit Sub
    End If
   

  s =     "If(itm.Custom1 = Category) Then:"
  s = s & "  itm.Custom1 = '''':"
  s = s & "  itm.UpdateDB:"
  s = s & "End If:"
'  s = s & "itm.Custom1 = Replace(itm.Custom1, '', ''&Category&'', '', '', ''):" 'line removed 2/1/8, error found by jd776. WKW
  s = s & "itm.Custom1 = Replace(itm.Custom1, Category&'', '', ''''):"
  s = s & "itm.Custom1 = Replace(itm.Custom1, '', ''&Category, ''''):"
   s = s & "itm.UpdateDB:"
  s = Replace(s, "''", Chr(34))
  kwExecuteStatement Replace(s, "Category", kwToString(Category))
End Sub



Sub AddValueToTrackNum
  ' Define variables
  Dim value, s

  value = Trim(SkinnedInputBox("Add how much?", "Add To Track#", ""))
    if (value = "") then
      Exit Sub
    End If
	
  s =     "  itm.TrackOrder = itm.TrackOrder + value:"
  s = s & "  itm.UpdateDB"

  kwExecuteStatement Replace(s, "value", value)

End Sub



'--------------------------------------------------------------------------
'these are SQL statements, which aren't worth using the kwExecuteStatement



Sub SynchronizeCustom1
  ' Define variables 
  Dim list, iter, itm, i, query

    
  ' Get list of selected tracks from MediaMonkey 
  Set list = SDB.SelectedSongList 
  If list.count=0 Then 
  Set list = SDB.AllVisibleSongList 
  End If  

  ' Process all selected tracks 
  For i=0 To list.count-1 
    Set itm = list.Item(i) 
    query = "SELECT DISTINCT Custom1 FROM Songs WHERE Songs.ID<>"&itm.ID&" AND IDAlbum="&itm.Album.ID&" AND IDArtist="&itm.Artist.ID&" AND SongTitle='"&Replace(itm.Title,"'","''")&"'"
'    SDB.MessageBox query, mtError, Array(mbOk)
    Set iter = SDB.Database.OpenSQL(query)
    ' Copy custom1

    itm.Custom1 = iter.StringByName("Custom1")

    ' Update the changes in DB 
    itm.UpdateDB 

    Iter.next 
  Next 
End Sub 



'------------------------------
'This can be cleaned up some day due to new ways to access the classifications. It'd probably be faster than repeated DB queries, but this way seems to still work fine. WKW
'------------------------------
Function kwBackupClassificationToField(classification, field)
  Dim i, itm, iter, list
  ' Get list of selected tracks from MediaMonkey 
  Set list = SDB.SelectedSongList 
  If list.count=0 Then 
  Set list = SDB.AllVisibleSongList 
  End If  

  ' Process all selected tracks 
  For i=0 To list.count-1 
    Set itm = list.Item(i) 
    Set iter = SDB.Database.OpenSQL("SELECT Lists.TextData FROM Songs,AddSongInfoInt,Lists WHERE Lists.idListType = "&ClassificationDict.Item(classification)&" AND Lists.Id = AddSongInfoInt.intData AND AddSongInfoInt.idSong = "&itm.ID) 

    ' Swap the fields 
    Execute kwToCommand( field&" = Iter.StringByName("&kwToString("TextData")&")" )

    ' Update the changes in DB 
    itm.UpdateDB 

    iter.next 
  Next
End Function
Sub BackupClassificationToCustom3 
  ' Define variables 
  Dim classification 

  classification = UCase(SkinnedInputBox("Enter the classification to back up", "Define Classification", "MOOD")) 
   if (classification = "") then 
      Exit Sub 
   End If 
  kwBackupClassificationToField classification, "<CUSTOM3>"
End Sub
Last edited by W. Kyle White on Sat Feb 02, 2008 4:29 pm, edited 11 times in total.

Anubis
Posts: 439
Joined: Fri Feb 04, 2005 4:57 pm
Location: Sydney, Australia

Post by Anubis » Sun Jul 31, 2005 1:50 am

Thanks. I haven't tried your scripts yet, but they are a good idea.
It's good to get scripts in the public domain, for one, it gives other people some functionality, but it also can be improved on, and of course, it gives you a backup. :-)

Speaking of which, I should publish a couple my scripts too...

rogerr
Posts: 106
Joined: Sat Nov 15, 2003 8:02 pm

Post by rogerr » Sun Aug 07, 2005 1:30 pm

Thanks for these useful scripts. Would you concider adding an option to the swap tag script to include support for the COMMENT field?

Daniel

How to swap "Album" and "Album Artist"?

Post by Daniel » Sat Nov 05, 2005 5:59 am

Sorry Guys, but I'm a bit of an idiot and cannot figure out how to alter the existing script "swap title and artist". Could anyone please post the script?

Thanks a lot!

rogerr
Posts: 106
Joined: Sat Nov 15, 2003 8:02 pm

Post by rogerr » Sat Nov 05, 2005 12:40 pm

I looked at altering the script to support the "comment" field but could not understand how to do it. Perhaps the author can help us?

W. Kyle White
Posts: 8
Joined: Sat Apr 30, 2005 1:32 pm

Adding Comment field

Post by W. Kyle White » Thu Nov 10, 2005 3:13 am

Sorry, I've not been on the forums in a while. There was a question about adding the comment field to the script (great idea BTW). This field, and any other field that is a string in ISDBSongData (look in mediamonkeyscripting.chm which can be downloaded from the developer's section of the website) can be easily added to the fieldDict at the top of the script. Add a line
.Add "<COMMENT>" = "Comment"
and you can use the field anywhere you would use one of the string fields. I've edited my original post to include the comment field in the script.

For any other field the format should be
.Add "<WHATEVERYOUWANTTOCALLIT>" = "exactfieldnameinISDBSongData"
Last edited by W. Kyle White on Sat Feb 02, 2008 3:48 pm, edited 3 times in total.

W. Kyle White
Posts: 8
Joined: Sat Apr 30, 2005 1:32 pm

Swapping Artist and Album Artist

Post by W. Kyle White » Thu Nov 10, 2005 3:23 am

Daniel, are you looking for another script, asking where in my script the swap code is located, or asking how to use my scripts to swap artist and album artist. If you're wanting to use my script and have it set up correctly you can just select the song, select the "Swap two fields" script, and then enter ARTIST in the first text box and ALBUMARTIST in the second text box (not case sensitive).

TequilaM

could it be modified to have all classifications backed up?

Post by TequilaM » Tue Oct 31, 2006 7:41 pm

I used Tempo, Mood, and Occasion to classify all of my thousands of songs, but I didn't realize that I can't use them the way I want.

This script seems to take 1 of these classifications and put them into Custom3. Could it be modified to take all of them and put them into Custom3, or better yet, into the Comments?

So if I have: Tempo=Slow, Mood=Happy, and Ocassion=Party, it could put "Slow Happy Party" into the Comments3 or Comments field?

I'm not a coder, but I could really use this. Could someone help? Maybe point me in the right direction?

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Tue Oct 31, 2006 8:34 pm

Code: Select all

Sub WriteComments3
    Dim List : Set List = SDB.CurrentSongList
    Dim i, Song
    For i = 0 To List.Count - 1
        Set Song = List.Item(i)
        Song.Comment = Song.Tempo & " " & Song.Mood & " " & Song.Occasion
    Next
    List.UpdateAll
End Sub
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

TequilaM

You RULE, Steegy, you RULE!

Post by TequilaM » Tue Oct 31, 2006 9:41 pm

You just made my Halloween night. Thanks!!!

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

Post by trixmoto » Tue Apr 17, 2007 4:52 am

I've just fixed the code becuase there was a double quote missing. Thanks for pointing it out Bex. :)
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

jd776
Posts: 1
Joined: Tue Jun 05, 2007 12:08 am
Location: Netherlands Antilles

Fixed bug in RemoveCategoryFromCustom1

Post by jd776 » Tue Jun 05, 2007 12:24 am

Firstly, I would like to send out big thanks to W. Kyle White and the other posters for making these scripts available.

I found a problem with the RemoveCategoryFromCustom1 sub and I am posting the fix.

The problem: When you add three categories, then remove the second category the comma between the first category and the third category disappears, thereby fusing the first and third categories together.

I replaced

Code: Select all

s = s & "itm.Custom1 = Replace(itm.Custom1, '', ''&Category&'','', ''''):"

Code: Select all

  s = s & "itm.Custom1 = Replace(itm.Custom1, '', ''&Category&'', '', '', ''):"
And now it works! :)


Here is the Sub with the change included:

Code: Select all

Sub RemoveCategoryFromCustom1 
  ' Define variables 
  Dim category, s 

  category = Trim(SkinnedInputBox("Enter the Category to remove", "Remove Category", "Blah"&Chr(34))) 
    if (category = "") then 
      Exit Sub 
    End If 
    

  s =     "If(itm.Custom1 = Category) Then:" 
  s = s & "  itm.Custom1 = '''':" 
  s = s & "  itm.UpdateDB:" 
  s = s & "End If:" 
  s = s & "itm.Custom1 = Replace(itm.Custom1, '', ''&Category&'', '', '', ''):"
  s = s & "itm.Custom1 = Replace(itm.Custom1, Category&'', '', ''''):" 
  s = s & "itm.Custom1 = Replace(itm.Custom1, '', ''&Category, ''''):" 
   s = s & "itm.UpdateDB:" 
  s = Replace(s, "''", Chr(34)) 
  kwExecuteStatement Replace(s, "Category", kwToString(Category)) 
End Sub 

Rojer
Posts: 65
Joined: Tue Aug 22, 2006 5:06 am

Post by Rojer » Sun Jun 10, 2007 4:04 am

I am trying to use this script to change the path for the whole library. The idea is simple : run the script to change path in db and then just move the files in explorer.

I believe this would be better than either:
  • Auto organize function : I have more than one organization patterns and I am not willing to mess with them
    Find moved tracks : this works only partially (16.000 files found over 41.000.
The reason I want to do this is that the mp3 dedicated drive is full and I have installed a raid (1000 GB). Thing is I don't want the new drive to be dedicated to mp3's anymore : way too big and performing for this. Hence I need the files to be stored in a mp3 subfolder instead of the root.

So as for now, the files are still stored in root.

I installed the script and added a line in FieldDict:

Code: Select all

.Add "<PATH>", "Path" 
Then I just replace :\ with :\Mp3's\

This seems to work except MM will actually move the files ! This triggers dialog boxes about attached files, which is impossible. Plus, if I don't mind messing with the mdb file, I am not comfortable with letting the script actually handle such large amounts of data without any safety net.

Well actually, I have cloned the drive before running the script, but I believe most people can't.

Would it be possible to make the script change the field without actually reflecting the changes in the filesystem ? In case of mistake, a mere database restoration would fix the whole thing, which is better than restoring the actual data.

Last point is that moving the mp3 folders in Windows Explorer takes about 1 second, while MM while actually rename the files and check for attached files, which takes forever.
Last edited by Rojer on Sun Jun 10, 2007 6:11 am, edited 1 time in total.

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Sun Jun 10, 2007 5:29 am

The only way to change the paths without letting MM move the tracks is (I think) by changing the path directly in the database (manually with MSAccess or with a script using SQL query).
When you do this through MediaMonkey (manually with MediaMonkey or with a script using MediaMonkey's functions), it'll move the files on the FS too.

So, maybe a simple "find & replace" within MSAccess is the simplest (not even the need for a script).
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Rojer
Posts: 65
Joined: Tue Aug 22, 2006 5:06 am

Post by Rojer » Sun Jun 10, 2007 5:59 am

Thanks Steegy,

Unfortunately, I do not own msoffice, so that I cannot run this simple search and replace. I usually edit the database in Open Office 2.2 'sbase', which is enough for simple operations, like changing the media serial number.

I was not able to find a convenient way to replace a text string in a field, either by query or sql.

What i need is to run a simple UPDATE with string replace arguments:

Code: Select all

UPDATE Songs SET SongPath = REPLACE(SongPath,'\:\\', '\:\\Music\\MediaMonkey\\Mp3\'s\\')
This would replace the root (D:\) With a deeper path (f:\Data\Music\MediaMonkey\Mp3's)

Unfortunately, it appears that the Sql support in Open Office Base is limited to SELECT queries, plus a few others that do not appear to be documented in any easily available place. The UPDATE function, or at least the REPLACE" is definitely not there.

It still bugs me that I should buy a multi$ bloatware just to perform a nasty text search and replace in a locked document. This is definitely the bigger bummer about Media Monkey : wonder how Microsoft managed to fool talented programmers into this net.

Still, I find it odd for MM to actually alter the file system after running the script... Anyway, this script seems to allow great things and i am sure I will make some profit of it.

Post Reply