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