Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: Re: Opening files one by one

$
0
0

Sorry, I supposed putting my reply in context would help

 

I wanted to modify the script in the previous post to run a function instead of an action. I was able to make it work, sort of. But I think that my issue is the function I have set up.

 

function newDocFromLayer(docName,layerName){    docName == undefined ? docName = "Untitled":docName;    layerName == undefined ? layerName = activeDocument.activeLayer.name:layerName;    var desc = new ActionDescriptor();        var ref = new ActionReference();        ref.putClass( charIDToTypeID( "Dcmn" ) );    desc.putReference( charIDToTypeID( "null" ), ref );    desc.putString( charIDToTypeID( "Nm  " ), docName );        var ref1 = new ActionReference();        ref1.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );    desc.putReference( charIDToTypeID( "Usng" ), ref1 );    desc.putString( charIDToTypeID( "LyrN" ), layerName );
executeAction( charIDToTypeID( "Mk  " ), desc, DialogModes.NO );
};
//newDocFromLayer ();
#target photoshop
var theFolder = Folder.selectDialog ("select folder");
if (theFolder) {
var theFiles = theFolder.getFiles(/\.(jpg|tif|eps|psd)$/i);
for (var m = 0; m < theFiles.length; m++) {
var thisFile = app.open(File(theFiles[m]));
newDocFromLayer ();
}
};

 

What I wanted to do was open each file in a folder, and then copy all of the layers from each file into a new doc. Right now, It's opening each file in the folder, ad copying a single layer group to a new doc.

 

let me know if you think I should start a new thread, I don't want to hijack this one!


Viewing all articles
Browse latest Browse all 27456


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>