Save and Save as, fill Author when no author present?

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

Save and Save as, fill Author when no author present?

Post by Mcquiff »

Hi This is a couple of scripts that currently work well for me, they append file info when I go to save a file.
So it attaches the editter of the file as the description writer.

Save As function
Code: Select allfunction saveAS() {
if(!documents.length) return;
activeDocument.info.captionWriter = "Editted_by_Photographer";
if(activeDocument.layers.length > 1){
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putBoolean( stringIDToTypeID('maximizeCompatibility'), true );
desc2.putObject( charIDToTypeID('As  '), charIDToTypeID('Pht3'), desc3 );
try{executeAction( charIDToTypeID('save'), desc2, DialogModes.ALL );}catch(e){}
}else{
try{executeAction( charIDToTypeID('save'), undefined, DialogModes.ALL );}catch(e){}
}
};

saveAS();

Save

Code: Select allfunction saveAs() {
   if(!documents.length) return;
   activeDocument.info.captionWriter = "Editted_by_Photographer1";
   try{
      var currentFilePath = activeDocument.fullName;
   }catch(e){
      alert('Document has not been saved');
      return;
   }
   if(activeDocument.layers.length != 1){
      var saveFilePath = decodeURI(currentFilePath).replace(/\....?.$/i,'.psd');
      SaveAsPSD( saveFilePath, true, true );
   }else{
      var saveFilePath = decodeURI(currentFilePath).replace(/\....?.$/i,'.jpg');
      SaveAsJPEG( saveFilePath, 8, true );
   }
};
function SaveAsJPEG( inFileName, inQuality, inEmbedICC ) {
   var jpegOptions = new JPEGSaveOptions();
   jpegOptions.quality = inQuality;
   jpegOptions.embedColorProfile = inEmbedICC;
   app.activeDocument.saveAs( File( inFileName ), jpegOptions );
};
function SaveAsPSD( inFileName, inMaximizeCompatibility, inEmbedICC ) {
   var psdSaveOptions = new PhotoshopSaveOptions();
   psdSaveOptions.embedColorProfile = inEmbedICC;
   psdSaveOptions.maximizeCompatibility = inMaximizeCompatibility;
   app.activeDocument.saveAs( File( inFileName ), psdSaveOptions );
};

saveAs();

Now they work fine but I would like to add a little more info. I need it to check if there is an author name filled in? Now if it is blank I need it to prompt the user with "Who took this picture?"

with the options of Photographer A or Photographer B then to append this information in the Author, still with the additional information above (description writer).

If it is not blank the leave that field as is and then continue to add the description writer as above.

Many thanks for all those who have helped previously!! Matt