Retrieving and setting metadata 'Description' using jscript

Trying to make the simple button that sets the 'Description' field in the metadata panel from text in the clipboard.
Having trouble retrieving and setting metadata - Document properties - Description
image
for an image file using jscript.

        var file = source.selected(0);
        var description = file.metadata.image.desc;
        Log(description);

gives
image

how is this metadata field retrieved and set please.

Read

file.metadata.image.imagedesc

Write

SetAttr META imagedesc:heyho

Many thanks. Had to look at docs to get SetAttr without a double quote, this works:

var cmd = clickData.func.command;
var command = "";
command += 'SetAttr META "imagedesc:' + clip + '"';
cmd.AddLine(command);
cmd.Run();

Would the script work with longer text like this in the clipboard?

Hey! "comment:You just got punked!" FILE=C:\\*.jpg RECURSE

lol, nope
image
any fix ?

What to do when there's a space in the value is explained in Programmatic setting of Metadata.

The problem is if there is a double quote in the clipboard text.
Any work around for this, without parsing the text first and removing or changing all double quotes ?

Escaping the " characters in the clipboard text as \" should work.

(Remember that \ is also an escape character in JScript, so you'll need to use \\" in the code to get \".)

escaping the double quotes does not work
image

Doubling up the quotes should work.

Thanks. That works.
image

and here is finished button, has modifier to only work with images.
Set Description.dcf (6.2 KB)

Here is updated version 2 (without limit on text length)
Description.dcf (5.8 KB)