Search code examples
photoshop-script

How to duplicate the document in photoshop via scipt


I am new to scripting and I am stuck where I would like to duplicate the document in Photoshop via scripting so that document not get corrupted.

Please help.


Solution

  • hope the following code helps you

    function duplicateDocument() {
        var idDplc = charIDToTypeID("Dplc");
        var desc25 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref1 = new ActionReference();
        var idDcmn = charIDToTypeID("Dcmn");
        var idOrdn = charIDToTypeID("Ordn");
        var idFrst = charIDToTypeID("Frst");
        ref1.putEnumerated(idDcmn, idOrdn, idFrst);
        desc25.putReference(idnull, ref1);
        executeAction(idDplc, desc25, DialogModes.NO);
    }
    

    For more scripting help you can follow the following link https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2019.pdf