Skip to main content
askari97634760
Participant
November 25, 2018
Answered

Need to play action on certain Document

  • November 25, 2018
  • 1 reply
  • 281 views

I have a solution to save document's copy as JPG. However, I need to save file as Hi-Res and Lo-Res, and I convert to Lo-Res using some action with some manual steps, so I need to run that action between saving.

        var fileNameRoot = app.activeDocument.fullName.toString().slice( 0, -4 ); // copy the name without the extension

        var jpgDoc = app.activeDocument.duplicate( "JPGFILE", true );       // duplicate with merged layers

        jpgDoc.convertProfile( "sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true );    

        fileName = fileNameRoot+"_HI.jpg"

        saveFile( jpgDoc, fileName );

        app.doAction("Width 1500 px", "Basic");

        fileName = fileNameRoot+".jpg"

        saveFile( jpgDoc, fileName );

But here, app.doAction() does not specify where it is played; actually it works on activeDocument. But I need it to be played on jpgDoc.

saveFile is a wrapper for jpgDoc.saveAs() with some options.

How do I choose JPGFILE to be the document which is subjected to the action (active Document?)

This topic has been closed for replies.
Correct answer r-bin

But jpgDoc (which is JPGFILE) is already becoming the active document after the operation.

var jpgDoc = app.activeDocument.duplicate ("JPGFILE", true);


If you are still in doubt, you can execute the command

app.activeDocument = jpgDoc;

before

app.doAction ("Width 1500 px", "Basic");

1 reply

r-binCorrect answer
Legend
November 25, 2018

But jpgDoc (which is JPGFILE) is already becoming the active document after the operation.

var jpgDoc = app.activeDocument.duplicate ("JPGFILE", true);


If you are still in doubt, you can execute the command

app.activeDocument = jpgDoc;

before

app.doAction ("Width 1500 px", "Basic");