by tj_junk » Mon Feb 26, 2007 11:16 am
Try this improvement on TrixMoto's script... I modified the original script, using regular expressions to perform the pattern match, instead of "InStr()" commands. Regular expressions are much more powerful and flexible (but they do require a slight learning curve if you're unfamiliar).
Here are my notes from the modified script:
' - Uses regular expressions to improve the pattern matching capability and flexibility
' - Supports disc/cd numbers up to 20 (from the original author's max of 3)
' - Supports number strings (e.g., "Disc One")
' - Is case-insensitive
'
' Basically, it searches for the text "CD" or "Disc" followed by a "disc number"
' - The disc number can be represented by numeric digits (e.g. 1,2,3) or text (e.g., "one","two","three")
' - The disc number can be optionally preceded by the number sign (#) and/or white space
' - The entire string can be optionally enclosed by square brackets, curly brackets, or parentheses
' - The entire string can be optionally preceded by a single comma and/or white space
'
'=============================================================================================================================================
' NOTES:
'
' I. As in the original script, any disc number text (e.g., " (CD 1)" or ", [disc twelve]") is removed from the album text
' - An option could added in the future to "Modify album text (Y/N)?", defaulting to "Yes"
'
' II. I purposely chose not to mess with any preceding or trailing colon characters (":")
' - You could easily modify the regExpPatterns to your personal preference
'
' III. This script will detect false matches on album text such as "CD5", where "CD5" refers to a 5-inch CD single. Oh, well.
' - I suppose someone could implement an HTML popup that lets you preview/confirm changes (ala, Risser's Case Checker)
'
' IV. This script can be easily modified to support regional variations of the terms "CD" or "Disc" (e.g., "disque"),
as well as equivalents for the number text (e.g., "un", "deux", "trois").
'
' TO USE:
' - Use the MediaMonkey search tool (Ctrl-F) to look for "CD" or "Disc" (or a similar term) in the album field
' - Then, simply highlight the desired tracks and run the script ( Tools -> Script -> CombineAlbums )
Here is the modified script, in its entirety:
Code: Select all
'=============================================================================================================================================
'
' MediaMonkey Script
'
' NAME: CombineAlbums 1.0
'
' AUTHOR: trixmoto (http://trix.dork.com)
' DATE : 16/01/2006
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
' Set up text for your albums (see below: *)
'
' [CombineAlbums]
' FileName=CombineAlbums.vbs
' ProcName=CombineAlbums
' Order=18
' DisplayName=Combine Albums
' Description=Combine Albums
' Language=VBScript
' ScriptType=0
'
'=============================================================================================================================================
' MODIFIED BY: tj_junk
' DATE : 2007-02-26
'
' MODIFICATIONS:
'
' - Uses regular expressions to improve the pattern matching capability and flexibility
' - Supports disc/cd numbers up to 20 (from the original author's max of 3)
' - Supports number strings (e.g., "Disc One")
' - Is case-insensitive
'
' Basically, it searches for the text "CD" or "Disc" followed by a "disc number"
' - The disc number can be represented by numeric digits (e.g. 1,2,3) or text (e.g., "one","two","three")
' - The disc number can be optionally preceded by the number sign (#) and/or white space
' - The entire string can be optionally enclosed by square brackets, curly brackets, or parentheses
' - The entire string can be optionally preceded by a single comma and/or white space
'
'=============================================================================================================================================
' NOTES:
'
' I. As in the original script, any disc number text (e.g., " (CD 1)" or ", [disc twelve]") is removed from the album text
' - An option could added in the future to "Modify album text (Y/N)?", defaulting to "Yes"
'
' II. I purposely chose not to mess with any preceding or trailing colon characters (":")
' - You could easily modify the regExpPatterns to your personal preference
'
' III. This script will detect false matches on album text such as "CD5", where "CD5" refers to a 5-inch CD single. Oh, well.
' - I suppose someone could implement an HTML popup that lets you preview/confirm changes (ala, Risser's Case Checker)
'
' IV. This script can be easily modified to support regional variations of the terms "CD" or "Disc" (e.g., "disque"),
as well as equivalents for the number text (e.g., "un", "deux", "trois").
'
' TO USE:
' - Use the MediaMonkey search tool (Ctrl-F) to look for "CD" or "Disc" (or a similar term) in the album field
' - Then, simply highlight the desired tracks and run the script ( Tools -> Script -> CombineAlbums )
'=============================================================================================================================================
Option Explicit
Dim regExpPatterns, regExpPatternsList
regExpPatterns = ",?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(1|one|un)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(2|two|deux)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(3|three|trois)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(4|four|quatre)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(5|five|cinq)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(6|six)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(7|seven|sept)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(8|eight|huit)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(9|nine|neuf)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(10|ten|dix)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(11|eleven|onze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(12|twelve|douze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(13|thirteen|treize)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(14|fourteen|quatorze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(15|fifteen|quinze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(16|sixteen|seize)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(17|seventeen|dix-sept)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(18|eighteen|dix-huit)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(19|nineteen|dix-neuf)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(20|twenty|vingt)\b\s?[\]\}\)]?"
regExpPatternsList = Split(regExpPatterns,"&")
'==========================================================================================================
Sub CombineAlbums
Dim list,itm,prog,i,p,s,c
Set list = SDB.CurrentSongList
Set prog = SDB.Progress
prog.Text = "Initialising script..."
prog.MaxValue = list.Count
c = 0
Dim regEx, regExFound, j
Set regEx = New RegExp ' Create a regular expression.
regEx.ignoreCase = True ' Set case insensitivity.
For i=0 To list.Count-1
prog.Text = "Checking file "&(i+1)&" of "&list.Count&"..."
prog.Value = i
Set itm = list.Item(i)
s = itm.AlbumName
For j = 0 To UBound(regExpPatternsList)
regEx.pattern = regExpPatternsList(j)
regExFound = regEx.Test(s)
If regExFound Then
If itm.TrackOrder < 100 Then
c = c + 1
itm.AlbumName = regEx.Replace(s, "")
itm.TrackOrder = ((j+1)*100)+Itm.TrackOrder
End If
End If
Next
itm.UpdateDB
If prog.Terminate Then Exit For
Next
prog.Text = "Finalizing script..."
prog.Value = prog.MaxValue
p = SDB.MessageBox("Tracks updated: "&c&" out of "&list.Count,mtInformation,Array(mbOk))
Set prog = Nothing
End Sub
[color=blue]Try this improvement on TrixMoto's script... I modified the original script, using regular expressions to perform the pattern match, instead of "InStr()" commands. Regular expressions are much more powerful and flexible (but they do require a slight learning curve if you're unfamiliar).
[b]Here are my notes from the modified script:[/b][/color]
[quote]'[color=green] - Uses regular expressions to improve the pattern matching capability and flexibility
' - Supports disc/cd numbers up to 20 (from the original author's max of 3)
' - Supports number strings (e.g., "Disc One")
' - Is case-insensitive
'
' Basically, it searches for the text "CD" or "Disc" followed by a "disc number"
' - The disc number can be represented by numeric digits (e.g. 1,2,3) or text (e.g., "one","two","three")
' - The disc number can be optionally preceded by the number sign (#) and/or white space
' - The entire string can be optionally enclosed by square brackets, curly brackets, or parentheses
' - The entire string can be optionally preceded by a single comma and/or white space
'
'=============================================================================================================================================
' NOTES:
'
' I. As in the original script, any disc number text (e.g., " (CD 1)" or ", [disc twelve]") is removed from the album text
' - An option could added in the future to "Modify album text (Y/N)?", defaulting to "Yes"
'
' II. I purposely chose not to mess with any preceding or trailing colon characters (":")
' - You could easily modify the regExpPatterns to your personal preference
'
' III. This script will detect false matches on album text such as "CD5", where "CD5" refers to a 5-inch CD single. Oh, well.
' - I suppose someone could implement an HTML popup that lets you preview/confirm changes (ala, Risser's Case Checker)
'
' IV. This script can be easily modified to support regional variations of the terms "CD" or "Disc" (e.g., "disque"),
as well as equivalents for the number text (e.g., "un", "deux", "trois").
'
' TO USE:
' - Use the MediaMonkey search tool (Ctrl-F) to look for "CD" or "Disc" (or a similar term) in the album field
' - Then, simply highlight the desired tracks and run the script ( Tools -> Script -> CombineAlbums )[/color][/quote]
[color=blue][b]Here is the modified script, in its entirety:[/b][/color]
[code]'=============================================================================================================================================
'
' MediaMonkey Script
'
' NAME: CombineAlbums 1.0
'
' AUTHOR: trixmoto (http://trix.dork.com)
' DATE : 16/01/2006
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
' Set up text for your albums (see below: *)
'
' [CombineAlbums]
' FileName=CombineAlbums.vbs
' ProcName=CombineAlbums
' Order=18
' DisplayName=Combine Albums
' Description=Combine Albums
' Language=VBScript
' ScriptType=0
'
'=============================================================================================================================================
' MODIFIED BY: tj_junk
' DATE : 2007-02-26
'
' MODIFICATIONS:
'
' - Uses regular expressions to improve the pattern matching capability and flexibility
' - Supports disc/cd numbers up to 20 (from the original author's max of 3)
' - Supports number strings (e.g., "Disc One")
' - Is case-insensitive
'
' Basically, it searches for the text "CD" or "Disc" followed by a "disc number"
' - The disc number can be represented by numeric digits (e.g. 1,2,3) or text (e.g., "one","two","three")
' - The disc number can be optionally preceded by the number sign (#) and/or white space
' - The entire string can be optionally enclosed by square brackets, curly brackets, or parentheses
' - The entire string can be optionally preceded by a single comma and/or white space
'
'=============================================================================================================================================
' NOTES:
'
' I. As in the original script, any disc number text (e.g., " (CD 1)" or ", [disc twelve]") is removed from the album text
' - An option could added in the future to "Modify album text (Y/N)?", defaulting to "Yes"
'
' II. I purposely chose not to mess with any preceding or trailing colon characters (":")
' - You could easily modify the regExpPatterns to your personal preference
'
' III. This script will detect false matches on album text such as "CD5", where "CD5" refers to a 5-inch CD single. Oh, well.
' - I suppose someone could implement an HTML popup that lets you preview/confirm changes (ala, Risser's Case Checker)
'
' IV. This script can be easily modified to support regional variations of the terms "CD" or "Disc" (e.g., "disque"),
as well as equivalents for the number text (e.g., "un", "deux", "trois").
'
' TO USE:
' - Use the MediaMonkey search tool (Ctrl-F) to look for "CD" or "Disc" (or a similar term) in the album field
' - Then, simply highlight the desired tracks and run the script ( Tools -> Script -> CombineAlbums )
'=============================================================================================================================================
Option Explicit
Dim regExpPatterns, regExpPatternsList
regExpPatterns = ",?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(1|one|un)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(2|two|deux)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(3|three|trois)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(4|four|quatre)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(5|five|cinq)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(6|six)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(7|seven|sept)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(8|eight|huit)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(9|nine|neuf)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(10|ten|dix)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(11|eleven|onze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(12|twelve|douze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(13|thirteen|treize)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(14|fourteen|quatorze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(15|fifteen|quinze)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(16|sixteen|seize)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(17|seventeen|dix-sept)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(18|eighteen|dix-huit)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(19|nineteen|dix-neuf)\b\s?[\]\}\)]?" _
& "&,?\s?[\[\{\(]?(CD|Disc|Disque)\s?#?(20|twenty|vingt)\b\s?[\]\}\)]?"
regExpPatternsList = Split(regExpPatterns,"&")
'==========================================================================================================
Sub CombineAlbums
Dim list,itm,prog,i,p,s,c
Set list = SDB.CurrentSongList
Set prog = SDB.Progress
prog.Text = "Initialising script..."
prog.MaxValue = list.Count
c = 0
Dim regEx, regExFound, j
Set regEx = New RegExp ' Create a regular expression.
regEx.ignoreCase = True ' Set case insensitivity.
For i=0 To list.Count-1
prog.Text = "Checking file "&(i+1)&" of "&list.Count&"..."
prog.Value = i
Set itm = list.Item(i)
s = itm.AlbumName
For j = 0 To UBound(regExpPatternsList)
regEx.pattern = regExpPatternsList(j)
regExFound = regEx.Test(s)
If regExFound Then
If itm.TrackOrder < 100 Then
c = c + 1
itm.AlbumName = regEx.Replace(s, "")
itm.TrackOrder = ((j+1)*100)+Itm.TrackOrder
End If
End If
Next
itm.UpdateDB
If prog.Terminate Then Exit For
Next
prog.Text = "Finalizing script..."
prog.Value = prog.MaxValue
p = SDB.MessageBox("Tracks updated: "&c&" out of "&list.Count,mtInformation,Array(mbOk))
Set prog = Nothing
End Sub[/code]