• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

open image paste single click ?

Explorer ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Screenshot 2023-01-08 113026.jpg

TOPICS
Actions and scripting , Windows

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Jan 31, 2023 Jan 31, 2023

Copy link to clipboard

Copied

Opened JPEG image One by One  selected layer (The image will appear as many layers as are selected.
) are one click paste & As much as the image is being pasted, it should be closed....
just keep the top document hi open
 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 12, 2023 Feb 12, 2023

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 13, 2023 Feb 13, 2023

Copy link to clipboard

Copied

That thread has been replied to. It complicates the threads if you keep cross-linking.

DO post the  exact steps needed in your native language, it might help the coders understand what you want.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 13, 2023 Feb 13, 2023

Copy link to clipboard

Copied

Thanks to valuable reply...

sir i want that open jpeg image place should be in selected layer. But as much as the layer is selected, only that much image place should be there. in Top Document ...plz watch video Thanku

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

How to paste all the open Jpeg Images one by one ...in the selected layer in a single click.. on top document ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 23, 2023 Feb 23, 2023

Copy link to clipboard

Copied

Hello Community Expert....Sorry, I am posting one more time, plz Community Expert help me in this script....the number of layers I select is the number (count)of images place....If one layer is selected then one image and if more than one layer is selected then more than one image will be placed...that's all...thanku in advance..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2023 Feb 24, 2023

Copy link to clipboard

Copied

Please post the Script you are using now and describe how the images that are to be inserted are defined. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 24, 2023 Feb 24, 2023

Copy link to clipboard

Copied

thankans to reply... This script is working perfect, but it is placing only one image at a time, I need to Image as many layers as selected placed..If a layer is selected then an image is placed and if more than one layer is selected then as many layers as the image is placed.. thanku

 ( This script should be placed multi image. if possible )

 

// selected layer rename
var newName =("layer name", "frame");

var layers = getSelectedLayers();
for (var i = 0; i < layers.length; i ++){
	layers[i].name = newName;
}

function getSelectedLayers(){ 
	var idGrp = stringIDToTypeID( "groupLayersEvent" );
	var descGrp = new ActionDescriptor();
	var refGrp = new ActionReference();
	refGrp.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Trgt" ));
	descGrp.putReference(charIDToTypeID( "null" ), refGrp );
	executeAction( idGrp, descGrp, DialogModes.ALL );
	var resultLayers=new Array();
	for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}
	var id8 = charIDToTypeID( "slct" );
    var desc5 = new ActionDescriptor();
    var id9 = charIDToTypeID( "null" );
    var ref2 = new ActionReference();
    var id10 = charIDToTypeID( "HstS" );
    var id11 = charIDToTypeID( "Ordn" );
    var id12 = charIDToTypeID( "Prvs" );  
    ref2.putEnumerated( id10, id11, id12 );
	desc5.putReference( id9, ref2 );
	executeAction( id8, desc5, DialogModes.NO );
	return resultLayers;
}

// next document select,copy& close
var id26 = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var id27 = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var id28 = charIDToTypeID( "Dcmn" );
        ref3.putOffset( id28, 1 );
    desc9.putReference( id27, ref3 );
executeAction( id26, desc9, DialogModes.NO );
var id29 = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var id30 = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var id31 = charIDToTypeID( "Chnl" );
        var id32 = charIDToTypeID( "fsel" );
        ref4.putProperty( id31, id32 );
    desc10.putReference( id30, ref4 );
    var id33 = charIDToTypeID( "T   " );
    var id34 = charIDToTypeID( "Ordn" );
    var id35 = charIDToTypeID( "Al  " );
    desc10.putEnumerated( id33, id34, id35 );
executeAction( id29, desc10, DialogModes.NO );
var id36 = charIDToTypeID( "copy" );
executeAction( id36, undefined, DialogModes.NO );
var id37 = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var id38 = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var id39 = charIDToTypeID( "Chnl" );
        var id40 = charIDToTypeID( "fsel" );
        ref5.putProperty( id39, id40 );
    desc11.putReference( id38, ref5 );
    var id41 = charIDToTypeID( "T   " );
    var id42 = charIDToTypeID( "Ordn" );
    var id43 = charIDToTypeID( "None" );
    desc11.putEnumerated( id41, id42, id43 );
executeAction( id37, desc11, DialogModes.NO );
var id44 = charIDToTypeID( "Cls " );
executeAction( id44, undefined, DialogModes.NO );
// select rename layer & copy image placed
var id45 = charIDToTypeID( "slct" );
    var desc12 = new ActionDescriptor();
    var id46 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id47 = charIDToTypeID( "Lyr " );
        ref6.putName( id47, "frame" );
    desc12.putReference( id46, ref6 );
    var id48 = charIDToTypeID( "MkVs" );
    desc12.putBoolean( id48, false );
executeAction( id45, desc12, DialogModes.NO );
var id49 = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var id50 = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var id51 = charIDToTypeID( "Lyr " );
        ref7.putName( id51, "frame" );
    desc13.putReference( id50, ref7 );
    var id52 = charIDToTypeID( "MkVs" );
    desc13.putBoolean( id52, false );
executeAction( id49, desc13, DialogModes.NO );
var id53 = charIDToTypeID( "past" );
    var desc14 = new ActionDescriptor();
    var id54 = charIDToTypeID( "AntA" );
    var id55 = charIDToTypeID( "Annt" );
    var id56 = charIDToTypeID( "Anno" );
    desc14.putEnumerated( id54, id55, id56 );
executeAction( id53, desc14, DialogModes.NO );
var id57 = stringIDToTypeID( "newPlacedLayer" );
executeAction( id57, undefined, DialogModes.NO );
var oldPref = app.preferences.rulerUnits  
app.preferences.rulerUnits = Units.PIXELS;  
var doc = activeDocument;  
var iLayer = doc.activeLayer;  
  
layerDown ();  
  
var mLayerB = doc.activeLayer.bounds;  
doc.activeLayer = iLayer;  
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));  
iLayer.resize (scale*100,scale*100);  
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);  
  

function layerDown(){  
    var idslct = charIDToTypeID( "slct" );  
        var desc2 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref1 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idBckw = charIDToTypeID( "Bckw" );  
            ref1.putEnumerated( idLyr, idOrdn, idBckw );  
        desc2.putReference( idnull, ref1 );  
        var idMkVs = charIDToTypeID( "MkVs" );  
        desc2.putBoolean( idMkVs, false );  
        var idLyrI = charIDToTypeID( "LyrI" );  
            var list1 = new ActionList();  
            list1.putInteger( 3 );  
        desc2.putList( idLyrI, list1 );  
    executeAction( idslct, desc2, DialogModes.NO );  
    };
    createSmartObject(app.activeDocument.activeLayer);
function createSmartObject(layer)
{
    var idnewPlacedLayer = stringIDToTypeID( 'newPlacedLayer' );
    executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
}
        var oldPref = app.preferences.rulerUnits  
app.preferences.rulerUnits = Units.PIXELS;  
var doc = activeDocument;  
var iLayer = doc.activeLayer;  
  
layerDown ();  
  
var mLayerB = doc.activeLayer.bounds;  
doc.activeLayer = iLayer;  
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));  
iLayer.resize (scale*100,scale*100);  
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);  
  
clip ();  
  
function clip(){  
    var idGrpL = charIDToTypeID( "GrpL" );  
        var desc7 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref6 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idTrgt = charIDToTypeID( "Trgt" );  
            ref6.putEnumerated( idLyr, idOrdn, idTrgt );  
        desc7.putReference( idnull, ref6 );  
    executeAction( idGrpL, desc7, DialogModes.NO );  
    };  
  
function layerDown(){  
    var idslct = charIDToTypeID( "slct" );  
        var desc2 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref1 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idBckw = charIDToTypeID( "Bckw" );  
            ref1.putEnumerated( idLyr, idOrdn, idBckw );  
        desc2.putReference( idnull, ref1 );  
        var idMkVs = charIDToTypeID( "MkVs" );  
        desc2.putBoolean( idMkVs, false );  
        var idLyrI = charIDToTypeID( "LyrI" );  
            var list1 = new ActionList();  
            list1.putInteger( 3 );  
        desc2.putList( idLyrI, list1 );  
    executeAction( idslct, desc2, DialogModes.NO );  
    };  
        var id3 = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Lyr " );
        var id6 = charIDToTypeID( "Ordn" );
        var id7 = charIDToTypeID( "Bckw" );
        ref1.putEnumerated( id5, id6, id7 );
    desc2.putReference( id4, ref1 );
    var id8 = charIDToTypeID( "MkVs" );
    desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );

var id9 = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var id10 = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var id11 = charIDToTypeID( "Lyr " );
        var id12 = charIDToTypeID( "Ordn" );
        var id13 = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( id11, id12, id13 );
    desc3.putReference( id10, ref2 );
    var id14 = charIDToTypeID( "T   " );
        var desc4 = new ActionDescriptor();
        var id15 = charIDToTypeID( "Nm  " );
        desc4.putString( id15, "photoframe" );
    var id16 = charIDToTypeID( "Lyr " );
    desc3.putObject( id14, id16, desc4 );
executeAction( id9, desc3, DialogModes.NO );

var id3 = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Lyr " );
        var id6 = charIDToTypeID( "Ordn" );
        var id7 = charIDToTypeID( "Frwr" );
        ref1.putEnumerated( id5, id6, id7 );
    desc2.putReference( id4, ref1 );
    var id8 = charIDToTypeID( "MkVs" );
    desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );

var id82 = charIDToTypeID( "setd" );
    var desc15 = new ActionDescriptor();
    var id83 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id84 = charIDToTypeID( "Lyr " );
        var id85 = charIDToTypeID( "Ordn" );
        var id86 = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( id84, id85, id86 );
    desc15.putReference( id83, ref6 );
    var id87 = charIDToTypeID( "T   " );
        var desc16 = new ActionDescriptor();
        var id88 = charIDToTypeID( "Nm  " );
        desc16.putString( id88, "IMAGE LAYER" );
    var id89 = charIDToTypeID( "Lyr " );
    desc15.putObject( id87, id89, desc16 );
executeAction( id82, desc15, DialogModes.NO );

        // need to skip files Photoshop can't open
        // could also be done via a file filter

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 24, 2023 Feb 24, 2023

Copy link to clipboard

Copied

By selecting the layer and running the script, only one image is being placed by this script, as many layers should be selected. plz help this script

// selected layer rename
var newName =("layer name", "frame");

var layers = getSelectedLayers();
for (var i = 0; i < layers.length; i ++){
	layers[i].name = newName;
}

function getSelectedLayers(){ 
	var idGrp = stringIDToTypeID( "groupLayersEvent" );
	var descGrp = new ActionDescriptor();
	var refGrp = new ActionReference();
	refGrp.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Trgt" ));
	descGrp.putReference(charIDToTypeID( "null" ), refGrp );
	executeAction( idGrp, descGrp, DialogModes.ALL );
	var resultLayers=new Array();
	for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}
	var id8 = charIDToTypeID( "slct" );
    var desc5 = new ActionDescriptor();
    var id9 = charIDToTypeID( "null" );
    var ref2 = new ActionReference();
    var id10 = charIDToTypeID( "HstS" );
    var id11 = charIDToTypeID( "Ordn" );
    var id12 = charIDToTypeID( "Prvs" );  
    ref2.putEnumerated( id10, id11, id12 );
	desc5.putReference( id9, ref2 );
	executeAction( id8, desc5, DialogModes.NO );
	return resultLayers;
}

// next document select,copy& close
var id26 = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var id27 = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var id28 = charIDToTypeID( "Dcmn" );
        ref3.putOffset( id28, 1 );
    desc9.putReference( id27, ref3 );
executeAction( id26, desc9, DialogModes.NO );
var id29 = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var id30 = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var id31 = charIDToTypeID( "Chnl" );
        var id32 = charIDToTypeID( "fsel" );
        ref4.putProperty( id31, id32 );
    desc10.putReference( id30, ref4 );
    var id33 = charIDToTypeID( "T   " );
    var id34 = charIDToTypeID( "Ordn" );
    var id35 = charIDToTypeID( "Al  " );
    desc10.putEnumerated( id33, id34, id35 );
executeAction( id29, desc10, DialogModes.NO );
var id36 = charIDToTypeID( "copy" );
executeAction( id36, undefined, DialogModes.NO );
var id37 = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var id38 = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var id39 = charIDToTypeID( "Chnl" );
        var id40 = charIDToTypeID( "fsel" );
        ref5.putProperty( id39, id40 );
    desc11.putReference( id38, ref5 );
    var id41 = charIDToTypeID( "T   " );
    var id42 = charIDToTypeID( "Ordn" );
    var id43 = charIDToTypeID( "None" );
    desc11.putEnumerated( id41, id42, id43 );
executeAction( id37, desc11, DialogModes.NO );
var id44 = charIDToTypeID( "Cls " );
executeAction( id44, undefined, DialogModes.NO );
// select rename layer & copy image placed
var id45 = charIDToTypeID( "slct" );
    var desc12 = new ActionDescriptor();
    var id46 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id47 = charIDToTypeID( "Lyr " );
        ref6.putName( id47, "frame" );
    desc12.putReference( id46, ref6 );
    var id48 = charIDToTypeID( "MkVs" );
    desc12.putBoolean( id48, false );
executeAction( id45, desc12, DialogModes.NO );
var id49 = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var id50 = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var id51 = charIDToTypeID( "Lyr " );
        ref7.putName( id51, "frame" );
    desc13.putReference( id50, ref7 );
    var id52 = charIDToTypeID( "MkVs" );
    desc13.putBoolean( id52, false );
executeAction( id49, desc13, DialogModes.NO );
var id53 = charIDToTypeID( "past" );
    var desc14 = new ActionDescriptor();
    var id54 = charIDToTypeID( "AntA" );
    var id55 = charIDToTypeID( "Annt" );
    var id56 = charIDToTypeID( "Anno" );
    desc14.putEnumerated( id54, id55, id56 );
executeAction( id53, desc14, DialogModes.NO );
var id57 = stringIDToTypeID( "newPlacedLayer" );
executeAction( id57, undefined, DialogModes.NO );
var oldPref = app.preferences.rulerUnits  
app.preferences.rulerUnits = Units.PIXELS;  
var doc = activeDocument;  
var iLayer = doc.activeLayer;  
  
layerDown ();  
  
var mLayerB = doc.activeLayer.bounds;  
doc.activeLayer = iLayer;  
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));  
iLayer.resize (scale*100,scale*100);  
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);  
  

function layerDown(){  
    var idslct = charIDToTypeID( "slct" );  
        var desc2 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref1 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idBckw = charIDToTypeID( "Bckw" );  
            ref1.putEnumerated( idLyr, idOrdn, idBckw );  
        desc2.putReference( idnull, ref1 );  
        var idMkVs = charIDToTypeID( "MkVs" );  
        desc2.putBoolean( idMkVs, false );  
        var idLyrI = charIDToTypeID( "LyrI" );  
            var list1 = new ActionList();  
            list1.putInteger( 3 );  
        desc2.putList( idLyrI, list1 );  
    executeAction( idslct, desc2, DialogModes.NO );  
    };
    createSmartObject(app.activeDocument.activeLayer);
function createSmartObject(layer)
{
    var idnewPlacedLayer = stringIDToTypeID( 'newPlacedLayer' );
    executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
}
        var oldPref = app.preferences.rulerUnits  
app.preferences.rulerUnits = Units.PIXELS;  
var doc = activeDocument;  
var iLayer = doc.activeLayer;  
  
layerDown ();  
  
var mLayerB = doc.activeLayer.bounds;  
doc.activeLayer = iLayer;  
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));  
iLayer.resize (scale*100,scale*100);  
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);  
  
clip ();  
  
function clip(){  
    var idGrpL = charIDToTypeID( "GrpL" );  
        var desc7 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref6 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idTrgt = charIDToTypeID( "Trgt" );  
            ref6.putEnumerated( idLyr, idOrdn, idTrgt );  
        desc7.putReference( idnull, ref6 );  
    executeAction( idGrpL, desc7, DialogModes.NO );  
    };  
  
function layerDown(){  
    var idslct = charIDToTypeID( "slct" );  
        var desc2 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref1 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idBckw = charIDToTypeID( "Bckw" );  
            ref1.putEnumerated( idLyr, idOrdn, idBckw );  
        desc2.putReference( idnull, ref1 );  
        var idMkVs = charIDToTypeID( "MkVs" );  
        desc2.putBoolean( idMkVs, false );  
        var idLyrI = charIDToTypeID( "LyrI" );  
            var list1 = new ActionList();  
            list1.putInteger( 3 );  
        desc2.putList( idLyrI, list1 );  
    executeAction( idslct, desc2, DialogModes.NO );  
    };  
        var id3 = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Lyr " );
        var id6 = charIDToTypeID( "Ordn" );
        var id7 = charIDToTypeID( "Bckw" );
        ref1.putEnumerated( id5, id6, id7 );
    desc2.putReference( id4, ref1 );
    var id8 = charIDToTypeID( "MkVs" );
    desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );

var id9 = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var id10 = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var id11 = charIDToTypeID( "Lyr " );
        var id12 = charIDToTypeID( "Ordn" );
        var id13 = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( id11, id12, id13 );
    desc3.putReference( id10, ref2 );
    var id14 = charIDToTypeID( "T   " );
        var desc4 = new ActionDescriptor();
        var id15 = charIDToTypeID( "Nm  " );
        desc4.putString( id15, "photoframe" );
    var id16 = charIDToTypeID( "Lyr " );
    desc3.putObject( id14, id16, desc4 );
executeAction( id9, desc3, DialogModes.NO );

var id3 = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Lyr " );
        var id6 = charIDToTypeID( "Ordn" );
        var id7 = charIDToTypeID( "Frwr" );
        ref1.putEnumerated( id5, id6, id7 );
    desc2.putReference( id4, ref1 );
    var id8 = charIDToTypeID( "MkVs" );
    desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );

var id82 = charIDToTypeID( "setd" );
    var desc15 = new ActionDescriptor();
    var id83 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id84 = charIDToTypeID( "Lyr " );
        var id85 = charIDToTypeID( "Ordn" );
        var id86 = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( id84, id85, id86 );
    desc15.putReference( id83, ref6 );
    var id87 = charIDToTypeID( "T   " );
        var desc16 = new ActionDescriptor();
        var id88 = charIDToTypeID( "Nm  " );
        desc16.putString( id88, "IMAGE LAYER" );
    var id89 = charIDToTypeID( "Lyr " );
    desc15.putObject( id87, id89, desc16 );
executeAction( id82, desc15, DialogModes.NO );

        // need to skip files Photoshop can't open
        // could also be done via a file filter

M3aaspNtxn.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2023 Feb 25, 2023

Copy link to clipboard

Copied

Let me be frank: This Script seems problematic in several regards (the structure, the effectiveness [like the use of DOM workarounds for things that are directly available in AM], …) and your description seems equally problematic. 

Still, I tried to guess … 

// selected layer rename
var newName =("layer name", "frame");

//var layers = getSelectedLayers();
var layers = collectSelectedLayersAsDOM();
for (var i = 0; i < layers.length; i++){
	layers[i].name = newName;
};

for (var m = 0; m < layers.length; m++){
try {
// next document select,copy& close
var id26 = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var id27 = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var id28 = charIDToTypeID( "Dcmn" );
        ref3.putOffset( id28, 1 );
    desc9.putReference( id27, ref3 );
executeAction( id26, desc9, DialogModes.NO );
var id29 = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var id30 = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var id31 = charIDToTypeID( "Chnl" );
        var id32 = charIDToTypeID( "fsel" );
        ref4.putProperty( id31, id32 );
    desc10.putReference( id30, ref4 );
    var id33 = charIDToTypeID( "T   " );
    var id34 = charIDToTypeID( "Ordn" );
    var id35 = charIDToTypeID( "Al  " );
    desc10.putEnumerated( id33, id34, id35 );
executeAction( id29, desc10, DialogModes.NO );
var id36 = charIDToTypeID( "copy" );
executeAction( id36, undefined, DialogModes.NO );
var id37 = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var id38 = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var id39 = charIDToTypeID( "Chnl" );
        var id40 = charIDToTypeID( "fsel" );
        ref5.putProperty( id39, id40 );
    desc11.putReference( id38, ref5 );
    var id41 = charIDToTypeID( "T   " );
    var id42 = charIDToTypeID( "Ordn" );
    var id43 = charIDToTypeID( "None" );
    desc11.putEnumerated( id41, id42, id43 );
executeAction( id37, desc11, DialogModes.NO );
var id44 = charIDToTypeID( "Cls " );
executeAction( id44, undefined, DialogModes.NO );
// select rename layer & copy image placed
var id45 = charIDToTypeID( "slct" );
    var desc12 = new ActionDescriptor();
    var id46 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id47 = charIDToTypeID( "Lyr " );
        ref6.putName( id47, "frame" );
    desc12.putReference( id46, ref6 );
    var id48 = charIDToTypeID( "MkVs" );
    desc12.putBoolean( id48, false );
executeAction( id45, desc12, DialogModes.NO );
var id49 = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var id50 = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var id51 = charIDToTypeID( "Lyr " );
        ref7.putName( id51, "frame" );
    desc13.putReference( id50, ref7 );
    var id52 = charIDToTypeID( "MkVs" );
    desc13.putBoolean( id52, false );
executeAction( id49, desc13, DialogModes.NO );
var id53 = charIDToTypeID( "past" );
    var desc14 = new ActionDescriptor();
    var id54 = charIDToTypeID( "AntA" );
    var id55 = charIDToTypeID( "Annt" );
    var id56 = charIDToTypeID( "Anno" );
    desc14.putEnumerated( id54, id55, id56 );
executeAction( id53, desc14, DialogModes.NO );
var id57 = stringIDToTypeID( "newPlacedLayer" );
executeAction( id57, undefined, DialogModes.NO );
var oldPref = app.preferences.rulerUnits  
app.preferences.rulerUnits = Units.PIXELS;  
var doc = activeDocument;  
var iLayer = doc.activeLayer;  
  
layerDown ();  
  
var mLayerB = doc.activeLayer.bounds;  
doc.activeLayer = iLayer;  
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));  
iLayer.resize (scale*100,scale*100);  
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);  
  


    createSmartObject(app.activeDocument.activeLayer);
    
        var oldPref = app.preferences.rulerUnits  
app.preferences.rulerUnits = Units.PIXELS;  
var doc = activeDocument;  
var iLayer = doc.activeLayer;  
  
layerDown ();  
  
var mLayerB = doc.activeLayer.bounds;  
doc.activeLayer = iLayer;  
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));  
iLayer.resize (scale*100,scale*100);  
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);  
  
clip ();  
  
 
        var id3 = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Lyr " );
        var id6 = charIDToTypeID( "Ordn" );
        var id7 = charIDToTypeID( "Bckw" );
        ref1.putEnumerated( id5, id6, id7 );
    desc2.putReference( id4, ref1 );
    var id8 = charIDToTypeID( "MkVs" );
    desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );

var id9 = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var id10 = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var id11 = charIDToTypeID( "Lyr " );
        var id12 = charIDToTypeID( "Ordn" );
        var id13 = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( id11, id12, id13 );
    desc3.putReference( id10, ref2 );
    var id14 = charIDToTypeID( "T   " );
        var desc4 = new ActionDescriptor();
        var id15 = charIDToTypeID( "Nm  " );
        desc4.putString( id15, "photoframe" );
    var id16 = charIDToTypeID( "Lyr " );
    desc3.putObject( id14, id16, desc4 );
executeAction( id9, desc3, DialogModes.NO );

var id3 = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Lyr " );
        var id6 = charIDToTypeID( "Ordn" );
        var id7 = charIDToTypeID( "Frwr" );
        ref1.putEnumerated( id5, id6, id7 );
    desc2.putReference( id4, ref1 );
    var id8 = charIDToTypeID( "MkVs" );
    desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );

var id82 = charIDToTypeID( "setd" );
    var desc15 = new ActionDescriptor();
    var id83 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id84 = charIDToTypeID( "Lyr " );
        var id85 = charIDToTypeID( "Ordn" );
        var id86 = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( id84, id85, id86 );
    desc15.putReference( id83, ref6 );
    var id87 = charIDToTypeID( "T   " );
        var desc16 = new ActionDescriptor();
        var id88 = charIDToTypeID( "Nm  " );
        desc16.putString( id88, "IMAGE LAYER" );
    var id89 = charIDToTypeID( "Lyr " );
    desc15.putObject( id87, id89, desc16 );
executeAction( id82, desc15, DialogModes.NO );
} catch (e) {}
};
////////////////////////////////////
////////////////////////////////////
function layerDown(){  
    var idslct = charIDToTypeID( "slct" );  
        var desc2 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref1 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idBckw = charIDToTypeID( "Bckw" );  
            ref1.putEnumerated( idLyr, idOrdn, idBckw );  
        desc2.putReference( idnull, ref1 );  
        var idMkVs = charIDToTypeID( "MkVs" );  
        desc2.putBoolean( idMkVs, false );  
        var idLyrI = charIDToTypeID( "LyrI" );  
            var list1 = new ActionList();  
            list1.putInteger( 3 );  
        desc2.putList( idLyrI, list1 );  
    executeAction( idslct, desc2, DialogModes.NO );  
    };
function createSmartObject(layer) {
var idnewPlacedLayer = stringIDToTypeID( 'newPlacedLayer' );
executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
};
function getSelectedLayers(){ 
	var idGrp = stringIDToTypeID( "groupLayersEvent" );
	var descGrp = new ActionDescriptor();
	var refGrp = new ActionReference();
	refGrp.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Trgt" ));
	descGrp.putReference(charIDToTypeID( "null" ), refGrp );
	executeAction( idGrp, descGrp, DialogModes.ALL );
	var resultLayers=new Array();
	for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){
        resultLayers.push(app.activeDocument.activeLayer.layers[ix]);
    };
	var id8 = charIDToTypeID( "slct" );
    var desc5 = new ActionDescriptor();
    var id9 = charIDToTypeID( "null" );
    var ref2 = new ActionReference();
    var id10 = charIDToTypeID( "HstS" );
    var id11 = charIDToTypeID( "Ordn" );
    var id12 = charIDToTypeID( "Prvs" );  
    ref2.putEnumerated( id10, id11, id12 );
	desc5.putReference( id9, ref2 );
	executeAction( id8, desc5, DialogModes.NO );
    alert (resultLayers)
	return resultLayers;
};
function clip(){  
    var idGrpL = charIDToTypeID( "GrpL" );  
        var desc7 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref6 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idTrgt = charIDToTypeID( "Trgt" );  
            ref6.putEnumerated( idLyr, idOrdn, idTrgt );  
        desc7.putReference( idnull, ref6 );  
    executeAction( idGrpL, desc7, DialogModes.NO );  
    };
function layerDown(){  
    var idslct = charIDToTypeID( "slct" );  
        var desc2 = new ActionDescriptor();  
        var idnull = charIDToTypeID( "null" );  
            var ref1 = new ActionReference();  
            var idLyr = charIDToTypeID( "Lyr " );  
            var idOrdn = charIDToTypeID( "Ordn" );  
            var idBckw = charIDToTypeID( "Bckw" );  
            ref1.putEnumerated( idLyr, idOrdn, idBckw );  
        desc2.putReference( idnull, ref1 );  
        var idMkVs = charIDToTypeID( "MkVs" );  
        desc2.putBoolean( idMkVs, false );  
        var idLyrI = charIDToTypeID( "LyrI" );  
            var list1 = new ActionList();  
            list1.putInteger( 3 );  
        desc2.putList( idLyrI, list1 );  
    executeAction( idslct, desc2, DialogModes.NO );  
    };
////// collect bounds of selected layers //////
function collectSelectedLayersAsDOM () {
    // get selected layers;
        var selectedLayers = new Array;
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        var desc = executeActionGet(ref);
        if (desc.getBoolean(stringIDToTypeID("hasBackgroundLayer")) == true) {var theAdd =0}
        else {var theAdd = 1};
        if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
        desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
        var c = desc.count;
        var selectedLayers = new Array();
        // run through selected layers;
        for(var i=0;i<c;i++){
        var theIndex = desc.getReference( i ).getIndex()+theAdd;
        selectLayerByIndex(theIndex, false);
        selectedLayers.push(activeDocument.activeLayer);
        };
        // if only one:
        }else{
        selectedLayers = [activeDocument.activeLayer]
        };
        return selectedLayers
    };
// by mike hale, via paul riggott;
// http://forums.adobe.com/message/1944754#1944754
function selectLayerByIndex(index,add){ 
    add = undefined ? add = false:add 
    var ref = new ActionReference();
        ref.putIndex(charIDToTypeID("Lyr "), index);
        var desc = new ActionDescriptor();
        desc.putReference(charIDToTypeID("null"), ref );
           if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) ); 
          desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
       try{
        executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
    }catch(e){
    alert(e.message); 
    }
    };

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 25, 2023 Feb 25, 2023

Copy link to clipboard

Copied

LATEST

Thank you very much....work is perfectily..( Thanku)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines