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

Changing text color in multiple .psd's with actions

New Here ,
Sep 24, 2016 Sep 24, 2016

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.

TOPICS
Actions and scripting
3.9K
Translate
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

correct answers 1 Correct answer

Guide , Sep 25, 2016 Sep 25, 2016

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

...
Translate
Adobe
Community Expert ,
Sep 24, 2016 Sep 24, 2016

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

JJMack
Translate
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
New Here ,
Sep 24, 2016 Sep 24, 2016

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?

Translate
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 ,
Sep 24, 2016 Sep 24, 2016

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.

JJMack
Translate
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
New Here ,
Sep 24, 2016 Sep 24, 2016

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?

Translate
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 ,
Sep 24, 2016 Sep 24, 2016

Photoshop Scripting  dcumentation and scriptlistener plugin on Adobe site.

JJMack
Translate
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
Guide ,
Sep 25, 2016 Sep 25, 2016

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

};

Translate
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 ,
Sep 25, 2016 Sep 25, 2016

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.

JJMack
Translate
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
New Here ,
Oct 19, 2016 Oct 19, 2016

This works perfectly, thank you

Translate
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
Contributor ,
Oct 20, 2016 Oct 20, 2016

Supermerlin

I have more levels of text how do I edit them all?

Translate
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 ,
Oct 20, 2016 Oct 20, 2016

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.

JJMack
Translate
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
Guide ,
Oct 20, 2016 Oct 20, 2016

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){}

};

Translate
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 ,
Oct 20, 2016 Oct 20, 2016

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
}
JJMack
Translate
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 Beginner ,
Dec 04, 2021 Dec 04, 2021

I was Googling exactly for this method and found it! However, I get Error  1242 in the line "open(fileList);"

I know it has been years, but how to fix this?

Translate
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
LEGEND ,
Dec 04, 2021 Dec 04, 2021
LATEST

Ask JJMack to correct script changed due to forum transition (deleting for ex. [i] characters).

Translate
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