It turns out that writing vbscript to fix it wasn't that hard at all.
Create a new text file with the name fixdisc.vbs
and put the following into it:
Option Explicit
Dim oiTunes : Set oiTunes = CreateObject("iTunes.Application")
Dim oLibrary : Set oLibrary = oiTunes.LibraryPlaylist
Dim oTracks : Set oTracks = oLibrary.Tracks
Dim i, oSong, p, sDisk, sNewTitle, iTotal
iTotal = oTracks.Count
For i = 1 To iTotal
Set oSong = oTracks.Item(i)
For p = 1 To 4
sDisk = " (disc " & p & ")"
If Instr(1, oSong.Album, sDisk, vbTextCompare) > 0 Then
sNewTitle = Replace(oSong.Album, sDisk, "", 1, -1, vbTextCompare)
WScript.Echo i & "/" & iTotal & ": Setting '" & oSong.Album & "' to '" & sNewTitle & "' and disk number to " & p
' Remove the ' prefix on the next two lines to actually update the data!
' oSong.DiscNumber = p
' oSong.Album = sNewTitle
Exit For
End If
Next
Next
Set oSong = Nothing
Set oTracks = Nothing
Set oLibrary = Nothing
Set oiTunes = Nothing
Bring up a command prompt (using cmd
), navigate to the location of the script and type:
cscript fixdisc.vbs
The script will tell you what albums it will change but will not make the changes. When you're happy, edit the script and remove the '
from the two lines so the code looks like this:
' Remove the ' prefix on the next two lines to actually update the data!
oSong.DiscNumber = p
oSong.Album = sNewTitle
Exit For
End If
Now re-run the script and any tracks containing (disc x)
(where x is 1 to 4) will have the appropriate "Disc Number" meta-data populated and the album title will be updated to remove that string.
Caveats/warnings
- If you double click it from Windows, then you'll get spammed with pop-ups. So always run from the command line.
- I've not fully tested it, use at your own risk! (backup your library first)
- Only "disc x" will work, you can easily tweak it to support "disk x" if you want.
- Only disc numbers 1 to 4 will work, you can easily tweak it to do more.
- Complex disc numbers (eg. "Northern Exposure (disc 1: 0 degrees, north)") will not be corrected.
- It takes quite a long time to do and your iTunes library will jump around erratically as the data is corrected. Your PC gets a little bogged down too.
Enjoy.