Re writing Save to add meta data tag.

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Mcquiff

Re writing Save to add meta data tag.

Post by Mcquiff »

What I am trying to achieve is this,

When I save a file at the moment I select Save As using the shortcut keys.

However I want to automatically add some meta data to the file every time. So I would write a simple action within photoshop.

So File info
then Description Tag
Author (me) and maybe Author title (photographer)
Then the next part of the script would be in invoke the "Save as" Command, BUT ITS IMPORTANT TO NOTE I DON'T WANT IT TO AUTOMATICALLY SAVE. it needs to jst put the prompt on the screen so that filename type etc can be filled in manually.
Then once the script is made I can assign the keystroke CMD Shift S to this script, hide the save as function in the keyboard shortcuts/ menu items.

Then every time I go to save it would add the meta tags I need as I work?


Code: Select allvar idsetd = charIDToTypeID( "setd" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPrpr = charIDToTypeID( "Prpr" );
        var idFlIn = charIDToTypeID( "FlIn" );
        ref1.putProperty( idPrpr, idFlIn );
        var idDcmn = charIDToTypeID( "Dcmn" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idDcmn, idOrdn, idTrgt );
    desc7.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var desc8 = new ActionDescriptor();
        var idByln = charIDToTypeID( "Byln" );
        desc8.putString( idByln, """ME""" );
        var idBylT = charIDToTypeID( "BylT" );
        desc8.putString( idBylT, """Photographer""" );
    var idFlIn = charIDToTypeID( "FlIn" );
    desc7.putObject( idT, idFlIn, desc8 );
executeAction( idsetd, desc7, DialogModes.NO );

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

Re writing Save to add meta data tag.

Post by Paul MR »

Something like this....

Code: Select allfunction saveAS() {
if(!documents.length) return;
activeDocument.info.author = "Your name here";
try{executeAction( charIDToTypeID('save'), undefined, DialogModes.ALL );}catch(e){}
};

saveAS();
Mcquiff

Re writing Save to add meta data tag.

Post by Mcquiff »

Ah Fantastic So simple with a little help!

One more thing if the file is already saved and you want to hit the equivalent of CMD S "Save" How would I alter it to do the same? Add metadata then save?
Paul MR

Re writing Save to add meta data tag.

Post by Paul MR »

Same code but with DialogModes.NO

Code: Select allfunction saveAS() {
if(!documents.length) return;
activeDocument.info.author = "Your name here";
try{executeAction( charIDToTypeID('save'), undefined, DialogModes.NO );}catch(e){}
};

saveAS();
Mcquiff

Re writing Save to add meta data tag.

Post by Mcquiff »

Excellent many thanks for your help!!!
Mcquiff

Re writing Save to add meta data tag.

Post by Mcquiff »

Dam I thought I could hide the hide the save and save as functions in the file menus? Do you know a way around that ?
Paul MR

Re writing Save to add meta data tag.

Post by Paul MR »

Sorry but there is no way of modifing the Photoshop menus.
Mcquiff

Re writing Save to add meta data tag.

Post by Mcquiff »

Just noticed that by default, if the image opened is Jpg, then when it comes to save it wants to save as jpg, not as PSD even when the image contains lots of layers.

How can I change this default?