Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Cover art installer script (Read 6140 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Cover art installer script

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: [Select]
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: [Select]
wscript.exe "C:\Program Files\foobar2000 v0.9\scripts\image_rename.vbs" "%_foobar2000_version%" "$replace(%path%,'\'%filename_ext%,)" "%artist%" "%album%"

Cover art installer script

Reply #1
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?

Cover art installer script

Reply #2
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

Cover art installer script

Reply #3
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...."

Cover art installer script

Reply #4
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

 

Cover art installer script

Reply #5
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?