Copy link to clipboard
Copied
Is there a way to change color of text layers in multiple .psd files (with diffrent text in each one) with actions?
All the files I need to do that with are structured the same way - background and above a text layer.
Here are the basics...
...#target photoshop;
main();
function main(){
//select folder where PSDs are held
var selectFolder = Folder.selectDialog( "Please select folder of PSDs");
//if no folder selected quit.
if(selectFolder == null) return;
//get an array of all PSDs in the folder
var fileList = selectFolder.getFiles("*.psd");
//iterate through file list
for(var a in fileList){
var textColour = new SolidColor();
textColour.rgb.hexValue = "00ff00"; //set colour to green
open(fileList);
activeDocument.activeLayer
Copy link to clipboard
Copied
You should ask about actions in the Photoshop General Discussion forun this is a scripting forum. What you want to do would be better done using Photoshop Scripting IMO
Copy link to clipboard
Copied
If it would, then I better leave it here. So how could I change color of text layers in multiple .psd files (with diffrent text in each one) using Photoshop Scripting?
Copy link to clipboard
Copied
You would program a Photoshop script. If you do not have a programming background and know a supported scripting language like JavsScript. You would have a lot to learn. Scripting is not as easy as recording an action.
Copy link to clipboard
Copied
I messed around a bit with it and have a basic understanding of JavaScript, I'm also quite patient. Just point me in the right direction
Where should I start?
Copy link to clipboard
Copied
Photoshop Scripting dcumentation and scriptlistener plugin on Adobe site.
Copy link to clipboard
Copied
Here are the basics...
#target photoshop;
main();
function main(){
//select folder where PSDs are held
var selectFolder = Folder.selectDialog( "Please select folder of PSDs");
//if no folder selected quit.
if(selectFolder == null) return;
//get an array of all PSDs in the folder
var fileList = selectFolder.getFiles("*.psd");
//iterate through file list
for(var a in fileList){
var textColour = new SolidColor();
textColour.rgb.hexValue = "00ff00"; //set colour to green
open(fileList);
activeDocument.activeLayer = activeDocument.artLayers[0]; //Select top layer
if(activeDocument.activeLayer.kind == LayerKind.TEXT){ //check if it is a text layer
activeDocument.activeLayer.textItem.color = textColour; //set text to colour
activeDocument.save(); //Save changes
activeDocument.close(SaveOptions.DONOTSAVECHANGES); //Close document
}else{//not a text layer so close document
activeDocument.close(SaveOptions.DONOTSAVECHANGES); //Close document
}
}//end of filelist
};
Copy link to clipboard
Copied
As you can see in SuperMerlin script. A script can prompt a user to select folder of files to process using a system select folder dialog. The Script can filter the File Types it will process in that folder. creating a File list to process. He then filtered just PSD files using getFiles with a filter. The filter could have easily been a list of file types that could be layered files like PSD, PSB and TIFF. The for loop process the file list and each document is checked to see if the top layer is a text layer. If your document should only have two layers that test for the top layer could have had an additional condition to be met. If you document can have more than one text layer and you want to change all text layers colors the script could be coded to process all text layers in the documents. Logic like this is not possible in Actions.
Copy link to clipboard
Copied
This works perfectly, thank you
Copy link to clipboard
Copied
Supermerlin
I have more levels of text how do I edit them all?
Copy link to clipboard
Copied
If your document has more than one text layer and you want to change all text layers colors the script would loop through all the layers in your document and chang text layers color to the color you want them to be. Currently the script just look at the document top layer and if it is a text layer is sets the text layer color. You now need to look at all layers. And you would need to code a recursive function if your documents may have layer groups.
Copy link to clipboard
Copied
This will do ALL text layers in the PSD's
#target photoshop;
main();
function main(){
//select folder where PSDs are held
var selectFolder = Folder.selectDialog( "Please select folder of PSDs");
//if no folder selected quit.
if(selectFolder == null) return;
//get an array of all PSDs in the folder
var fileList = selectFolder.getFiles("*.psd");
//iterate through file list
for(var a in fileList){
var textColour = new SolidColor();
textColour.rgb.hexValue = "00ff00"; //set colour to green
open(fileList);
//get a list of all text layers
var textLayers = getTextLayers();
//iterate text layers
for(var t in textLayers){
selectLayerByIndex(Number(textLayers
)); if(activeDocument.activeLayer.kind == LayerKind.TEXT){ //check if it is a text layer
activeDocument.activeLayer.textItem.color = textColour; //set text to colour
}
}
//Save changes if changes have been made
if(isDirty()) activeDocument.save();
activeDocument.close(SaveOptions.DONOTSAVECHANGES); //Close document
}//end of filelist
};
function isDirty(){
var ref = new ActionReference();
ref.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("isDirty"));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet(ref).getBoolean(stringIDToTypeID("isDirty"));
}
function getTextLayers(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "NmbL" ));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var count = executeActionGet(ref).getInteger(charIDToTypeID("NmbL")) +1;
var tlayers=[];
try{
activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
for(i;i<count;i++){
if(i == 0) continue;
ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), i );
var desc = executeActionGet(ref);
if (desc.hasKey(stringIDToTypeID("textKey"))) tlayers.push(i);
};
return tlayers;
};
function selectLayerByIndex(index,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){}
};
Copy link to clipboard
Copied
This code may be easier to read it is all DOM code SuperMerlin Action Manger code may be faster.
#target photoshop;
var textColour = new SolidColor();
textColour.rgb.hexValue = "00ff00"; //set colour to green
main();
function main(){
try{
//select folder where PSDs are held
var selectFolder = Folder.selectDialog( "Please select folder of PSDs");
//if no folder selected quit.
if(selectFolder == null) return;
//get an array of all PSDs in the folder
var fileList = selectFolder.getFiles("*.psd");
if (fileList) { //iterate through file list
for ( i=0;i<fileList.length;i++){
open(fileList[i]);
processArtLayers(activeDocument)
//activeDocument.save(); //Save changes
activeDocument.close(SaveOptions.DONOTSAVECHANGES); //Close document
}
}
}
catch(e) { alert(e + ': on line ' + e.line, 'Photoshop Error', true); }
};
function processArtLayers(obj) {
for( var i = obj.layers.length-1; 0 <= i; i--) {if (obj.layers[i].kind == LayerKind.TEXT) obj.layers[i].textItem.color = textColour;}
for( var i = obj.layerSets.length-1; 0 <= i; i--) {processArtLayers(obj.layerSets[i]); } // Process Layer Set Layers
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Ask JJMack to correct script changed due to forum transition (deleting for ex. [i] characters).