Squeezebox Server thumbnail creator

This script creates thumbnails for all cover images in the selected folder and subfolders. This speeds up the listings in Squeezebox. It uses Graphicsmagick for the actual converting.

I made this script because there was no easy way to do this in windows as there is no good find command like in *nix.

Save the script below as thumber.vbs and run from the command line:

cscript thumber.vbs "foldername"


cscript thumber.vbs "c:\My Music"

Dim fso, folder, folderName, coverFilenames, convertCommand, targetFilename

' Change this if you use other filenames
coverFilenames = "FOLDER.JPG,COVER.JPG"

' Change this if you want to use another target filename
targetFilename = "thumb.jpg"

' Change this if you want to use different parameters for converting the image
convertCommand = "gm convert -resize 50x50 ""#SOURCEFILENAME#"" ""#TARGETFILENAME#"""

If Wscript.Arguments.Count <> 1 Then
    WScript.Echo "Run from the command line: cscript thumber.vbs ""foldername"""
End If

folderName = Wscript.Arguments(0)

Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject ("WScript.Shell")

If Not fso.FolderExists(folderName) Then
    WScript.Echo "The folder """ & folderName & """ does not exist"
End If

WScript.Echo "Scanning """ & folderName & """"

Set folder = fso.GetFolder(folderName)


Function processFolders(folder)
    Dim subfolder


    For Each subfolder in folder.SubFolders
    Set subfolder = Nothing
End Function 

Function processFiles(folder) 
    Dim file, fileNames, cmd

    For Each file in folder.Files
      If InStr(coverFilenames, UCase(file.name)) > 0 Then
        cmd = convertCommand
        cmd = Replace(cmd,"#SOURCEFILENAME#",file.Path)
        cmd = Replace(cmd,"#TARGETFILENAME#",file.ParentFolder & "\" & targetFilename)
        Set cmdOutput = oShell.Exec(cmd)
        WScript.Echo cmdOutput.StdOut.ReadAll
      End If  
    Set file = Nothing
End Function