Option Explicit Function OnInit(initData) initData.name = "Command_AddJpgFromSelectionToMp3" initData.desc = "Add jpg files from selection to selected mp3." initData.min_version = "11.12" initData.copyright = "2015 Albator V (Michiels Thomas)" initData.version = "v1.0" initData.default_enable = true initData.config.ClearOutput = false initData.config.WriteOutput = false initData.config_desc = Dopus.Create.Map("ClearOutput", "Clear output when run command.", _ "WriteOutput", "Show messages in output.") End Function Function OnAddCommands(addCmdData) Dim cmd: Set cmd = addCmdData.AddCommand() cmd.name = "AddJpgFromSelectionToMp3" cmd.method = "OnAddJpgFromSelectionToMp3" cmd.desc = "Add jpg files from selection to selected mp3" cmd.label = "AddJpgFromSelectionToMp3" cmd.icon = "setwallpaper" End Function Function OnAddJpgFromSelectionToMp3(funcData) Dim ImageFile Dim strSelArrayJpg Dim NonMp3File Dim strInformation ' Clear log If script.config.ClearOutput = True Then Dopus.clearOutput ' Find jpg in selection strSelArrayJpg = Empty For Each ImageFile In funcData.func.sourcetab.selected If (Not ImageFile.is_dir) Then If Right(ImageFile,3) = "jpg" then If IsEmpty(strSelArrayJpg) Then ReDim strSelArrayJpg(0) Else ReDim Preserve strSelArrayJpg(UBound(strSelArrayJpg)+1) End If strSelArrayJpg(UBound(strSelArrayJpg)) = ImageFile End if End If Next ' Remove non mp3 file from command For Each NonMp3File In funcData.Func.Command.files If Right(NonMp3File,3) <> "mp3" Then funcData.Func.Command.RemoveFile (NonMp3File) Next ' Add jpg to selection If IsEmpty(strSelArrayJpg) Then If script.config.WriteOutput = True Then DOpus.OutputString "Alert: No jpg file in selection." Else Select Case UBound(strSelArrayJpg)+1 Case 1: strInformation = "Information: " & UBound(strSelArrayJpg)+1 & " jpg file to add." Case Else: strInformation = "Information: " & UBound(strSelArrayJpg)+1 & " jpg files to add." End Select If script.config.WriteOutput = True Then Dopus.OutputString strInformation For each ImageFile in strSelArrayJpg If script.config.WriteOutput = True Then Dopus.OutputString "Command sent: " & "SetAttr META ""coverart:+3:" & ImageFile & """" funcData.Func.Command.RunCommand "SetAttr META ""coverart:+3:" & ImageFile & """" Next End If End Function