Help - Search - Members - Calendar
Full Version: Cover art installer script
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Uploads - (fb2k)
crazysnailboy
I wrote this VBScript to ease the process of copying newly downloaded album covers into their relevant directory and naming them appropriately. I launch it using foo_run, and it moves the selected image to the same folder as the audio file and names it either "%artist% - %album% - images - front cover.*" or "%artist%.*".

CODE

option explicit

dim oFSO, oFile, oDialog
dim sDialogTitle, sFolderName, sArtist, sAlbum, sFileName

sDialogTitle = WScript.Arguments(0)
sFolderName = WScript.Arguments(1)
sArtist = WScript.Arguments(2) : sArtist = StripInvalidChars(sArtist)
sAlbum = WScript.Arguments(3) : sAlbum = StripInvalidChars(sAlbum)


set oDialog = WScript.CreateObject("UserAccounts.CommonDialog")
set oFSO = WScript.CreateObject("Scripting.FileSystemObject")

with oDialog
    .Filter = "Image Files|*.bmp;*.gif;*.jpg;*.png;|All Files|*.*|"
    .FilterIndex = 0
    if (.ShowOpen()) then

        set oFile = oFSO.getFile(.FileName)
        sFileName = sFolderName & "\" & sArtist
        if (sAlbum <> "") then
            sFileName = sFileName & " - " & sAlbum & " - Images - Front Cover"
        end if
        sFileName = sFileName & "." & LCase(oFSO.getExtensionName(oFile.Name))


        if not (oFSO.FileExists(sFileName)) then
            oFile.Move sFileName
        else
            if (MsgBox("Replace existing image?", vbYesNo + vbQuestion, sDialogTitle) = vbYes) then
                oFSO.DeleteFile sFileName
                oFile.Move sFileName
            end if
        end if


    end if
end with


WScript.DisconnectObject oFSO : set oFSO = nothing
WScript.DisconnectObject oDialog : set oDialog = nothing



function StripInvalidChars(byval sValue)
    sValue = Replace(sValue, "?", "")
    sValue = Replace(sValue, "/", "")
    sValue = Replace(sValue, "\", "")
    sValue = Replace(sValue, "*", "")
    StripInvalidChars = sValue
end function


Here's my foo_run command:
CODE
wscript.exe "C:\Program Files\foobar2000 v0.9\scripts\image_rename.vbs" "%_foobar2000_version%" "$replace(%path%,'\'%filename_ext%,)" "%artist%" "%album%"
san84
Thank you for your work!
I have another task. Is it possible to make a script for auto taging mp3s in folders with cover.jpg. I have a big collection sorted like this - artist\year album\mp3+cover.jpg.. But now I need my all artworks in tags, not in jpg files.. to use it with iPod. Can you help?
crazysnailboy
Off the top of my head, no, sorry. If you know of a command line utility which will embed the image into the tag, it should be fairly easy to write a script to automate it, but I'm not aware of such a tool.

Apparently iTunes can do it, but I've never used it. Or you could check this forum post and see if there's anything useful there...

http://www.hydrogenaudio.org/forums/index....showtopic=49145
Generalverdacht
seems really useful,

but im not quite sure what to to: i pasted the code in te large box to a file called "image_rename.vbs" and set the path in foo_run to this file, what to do with the other code? and if i run this script, there is the message: "acces denied on MS script host...."


crazysnailboy
Generalverdacht,

The code in the small box is the complete path string for foo_command. You should use all the code from the small box with foo_run, rather than just the name of the file.

I'm not sure why you're getting an access denied error message. Can you post the whole message?

Cheers,

Chris
nbv4
what do you mean by "it moves the selected image"? Are you supposed to add the newly downloaded file into the playlist? how is this script supposed to be used?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.