Need to play action on certain Document
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?)