Embed Itunes AlbumArt

iTunes doesn't embed its albumart into the MP3 files which means that non-Applic products don't get nice coverart which is really annoying.

Teridon wrote a script to embed them. John Jones edited this script and helpfully answered a few questions, while others on the forum kept adding more information to make it more helpful.

Here it is, with iTunes 11 support, with some step-by-step instructions, so you don't need to read all these forum posts or edit text files.

  1. Download the vbs script (call it itunes.vbs).

  2. Save it to c:\ drive (i.e. c:\itunes.vbs).

  3. Start up iTunes.

  4. Run command prompt (Start > Run > cmd).

  5. Type the following command %systemroot%\system32\cscript.exe c:\itunes.vbs

  6. Follow the on-screen instructions.

DO NOT just double-click the vbs file. Yeah I tried that. didn't work very well!

http://www.sheerboredom.net/2010/10/11/embed-album-artwork-from-itunes-into-mp3-files/

' ###############################################################################

' #

' # itunes_insert_artwork.vbs

' #

' # This script will tag your files using artwork downloaded using iTunes 10

' #

' # written by: Robert Jacobson (http://teridon.googlepages.com/itunesscripts)

' # Last Updated: 30 Jan 2012

' # Version 1.1

' #

' # This script is GPL v2. see http://www.gnu.org/copyleft/gpl.html

' #

' # Use option "-k" to keep the artwork files extracted

' # (in the same location as the song file)

' # (the default is to remove the files)

' #

' # Special Thanks to http://www.facebook.com/jrsousa2 for the error checking fix!

' #

' ###############################################################################

Option Explicit

Dim iTunesApp ' iTunes.Application object used to access the iTunes application.

Dim tracks ' The tracks collection object of the Library object.

Dim TrackPath ' The path to the track

Dim ArtPath ' The path to the artwork

Dim i ' A counter variable.

Dim Msg ' A string for a message.

Dim f ' A file object.

Dim sources

Dim source

Dim playlists

Dim playlist

Dim playlistName

Dim j

Dim m

Dim c

Dim songName

Dim artist

Dim result

Dim listarray

Dim num

Dim k

Dim track

Dim numtracks

Dim FormatArray(4)

Dim ExtArray(4)

Dim Artobj

Dim Art

Dim ArtDir

Dim Format

Dim BasePath

Dim fso

Dim NumFiles

Dim KeepFiles

Dim args

Dim arg

Dim IsDownlArtw_value

Dim erro_no

Dim erro_desc

Set fso = CreateObject("Scripting.FileSystemObject")

FormatArray(0) = "Unknown"

FormatArray(1) = "JPEG"

FormatArray(2) = "PNG"

FormatArray(3) = "BMP"

ExtArray(0) = "unk"

ExtArray(1) = "jpg"

ExtArray(2) = "png"

ExtArray(3) = "bmp"

Set iTunesApp = CreateObject("iTunes.Application.1")

Set sources = iTunesApp.Sources

Dim vers

vers = iTunesApp.Version

Dim Reg1

Set Reg1 = new RegExp

Reg1.Pattern = "^11"

if Reg1.Test(vers) Then

' yay

Else

Wscript.Echo "This script requires iTunes 10"

Wscript.Quit

End If

KeepFiles = False

Set args = WScript.Arguments

' Scan command line arguments

For Each arg in args

' Is it a flag.

If Instr(1, arg, "-", 1) = 1 or Instr(1, arg, "/", 1) = 1 Then

' Check for list flag

If UCase(arg) = "-K" or UCase(arg) = "/K" then

KeepFiles = True

End If

End If

Next

For i = 1 to sources.Count

Set source = sources.Item(i)

IF source.Kind = 1 Then

Set playlists = source.Playlists

Wscript.Echo "Select from the following playlists" & chr(13) & chr(10)

Wscript.Echo "Number of playlists: " & playlists.Count

For j = 1 to playlists.Count

Set playlist = playlists.Item(j)

playlistName = playlist.Name

Wscript.Echo j & ": " & playlistName

Next

Wscript.Echo ""

Wscript.StdOut.Write "Enter comma-separated lists to process: "

result = WScript.StdIn.ReadLine

listarray = split(result, ",")

For k = 0 to UBound(listarray)

num = listarray(k)

Set playlist = playlists.Item(num)

playlistName = playlist.Name

Wscript.Echo ""

Wscript.Echo chr(9) & "Processing playlist " & num & ": " & playlistName

Set tracks = playlist.Tracks

numtracks = tracks.Count

Wscript.Echo chr(9) & "tracks: " & numtracks

NumFiles = 0

For m = 1 to numtracks

If m > tracks.Count Then Exit For

Set track = tracks.Item(m)

'Wscript.Echo "num: " & numtracks & " Count: " & tracks.Count & " m: " & m

If track.Kind = 1 Then

songName = track.Name

artist = track.Artist

TrackPath = track.Location

Set Artobj = track.Artwork

For c = 1 to Artobj.Count

Set Art = Artobj.Item(c)

On Error Resume Next

if Art.IsDownloadedArtwork Then

'On Error Resume Next

IsDownlArtw_value = Art.IsDownloadedArtwork

erro_no = Err.Number

'Err.Clear

erro_desc = Err.Description

If Err.number <> 0 Then

IsDownlArtw_value = False

End If

if IsDownlArtw_value Then

Format = Art.Format

End If

'Wscript.Echo "Format is " & FormatArray(Format)

ArtDir = fso.GetParentFolderName(TrackPath)

'Wscript.Echo "Artdir is " & ArtDir

'ArtDir = fso.GetBaseName(ArtDir)

Dim RegX

Set RegX = new RegExp

RegX.Pattern = "[/:\\\*\?""""<>]"

RegX.Global = True

songName = RegX.Replace(songName, "-")

'songName = Replace(songName, "/", "-")

ArtPath = fso.BuildPath(ArtDir, songName & "." & ExtArray(Format))

Wscript.Echo "artpath is " & ArtPath

' save to file

Art.SaveArtworkToFile(ArtPath)

' insert from file into track tag

Art.SetArtworkFromFile(ArtPath)

if (KeepFiles) Then

' nothing

Else

fso.DeleteFile(ArtPath)

End If

NumFiles = NumFiles + 1

End If

Next

End If

Next

Wscript.Echo NumFiles & " files processed in playlist " & playlistName

Next

'End If

End If

Next