Add cover art to selection

Hi !

In folder, I have mp3 and jpg…
I want to easily add coverart to mp3.

Now, I copy jpg to clipboard, select mp3 and click Paste button in metapane.
I want to do the same thing with button or hotkey but command like "SetAttr META coverart:+clipboard" is missing.
Also if I copy more than one jpg, only the 1st is paste in mp3.

So I imagine 2 solutions…

Option 1
I copy jpg (1 or more) to clipboard.
I select some mp3 file and paste (button or hotkey) all jpg from clipboard to selection.

Option 2
I select jpg (1 or more) and some mp3 then paste (button or hotkey) all jpg to selection.

It’s possible to do something like this ?

"SetATTR META coverart:..." can take filenames for both the file to modify (see here) and the coverart (see here).

DOpus.GetClip and GetFlipFormat can get you a list of files from the clipboard (see here).

So it looks like something that should be possible, with those building blocks.

If I use SetAttr META "coverart:XXX", I need to replace XXX by file path.
How I can get file path of file in clipboard ?

Paste Empty File List has an example.

Do you need any additional assistence Albator? I could explain some details from the ClipboardEx add-in, it features a TextMagic prototype/object and some ready-to-use methods to get validated and sanitized content from clipboard.

With TextMagic it's only two lines of code to get all valid paths contained in the text-clipboard e.g:

var doItems = TextMagic.TextToDOItems( DOpus.GetClip("text") ); DOpus.Output("First file in text-clip: " + doItems[0].realpath);

It's ok, I create a new command.
Look if you see something wrong...
But I think create a new one, I'd rather to not use clipboard.
Commande_AddJpgFromClipboard.vbs.txt (2.67 KB)

I create new script command to add image to mp3 file.

So I select files (mp3 and image) then run script command.

But I don’t understand why images are not add to mp3 file. Can I have help please.

And little question: SetAttr command is sent to each file ? Even if he’s not a mp3 file ?
Commande_AddJpgFromSelection.vbs.txt (2.6 KB)

If you don't specify a FILE argument for the SetAttr command, it will run on all the files given to the command. Outside of a script, that means all the selected files. Inside a script, it is whichever files have been added to the Command object you are using. (funcData.Func.Command will have the selected files added to it by default, but you can change that using the appropriate methods on the Command object).

So you probably want to remove any non-mp3 files from the command object. I'm not sure if that is the only thing wrong, although I can't see anything obviously wrong from a quick look at the code.

What does the script output at the moment when you run it? Do the commands it runs look correct?

Oh, you might need to turn ImageFile into a full path, not just a filename, although I am not certain of that.

Nothing was display in script output, strange.
But I added an argument to setattr command, and it’s ok now.
Thanks Leo

It's not solved.
I've just add *.mp3 to SetAttr command, but this add images to all mp3 in source, not only selected file.

Do you mean you've literally written *.mp3 in the command string?

Yes, "Setattr *.mp3 META coverart:...", but in manual for FILE argument :
If you only specify the filename instead of the full path of the file or files, Opus will look in the current source folder.
So I need to have full path of each selected mp3 files.

If you tell it to do *.mp3 it will do *.mp3 in the current folder.

What I suggested above is that you add/remove whichever files you want from the Command object, then run SetAttr without any FILE argument at all, and it will act on the files attached to the command object. Look at the Command object methods like AddFile, RemoveFile, ClearFiles.

Thanks Leo, it's ok now.
I post scripts in Download forum if it can be useful to someone.

Command: Add cover art to selection