change all (TEXT ) layers color for multi *.psd's

New Here ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

hi guys..

I have a folder containing a lot of ( *.PSD files )

i need change all ( TEXT ) layers color for all thess *.PSD

just ( TEXT ) layers

 

i searched and i get this code and it's not work i have error message

#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

};

 

when i run scrpit and choose folder i get this error

semo5C92_0-1622301852866.png

this line 27

 

semo5C92_1-1622301897422.png

please help me

 

TOPICS
Actions and scripting

Views

960

Likes

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

correct answers 1 Correct Answer

Adobe Community Professional , May 29, 2021 May 29, 2021
Replace lines from 22 to 34 of your original code to: (sc = SolidColor).rgb.hexValue = '00ff00', lrs = [].slice.call((aD = open(fileList[a])).layers) while(lrs.length) (shft = lrs.shift()).kind == 'LayerKind.TEXT' ? shft.textItem.color = sc : shft.remove()

Likes

Translate

Translate
New Here ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

note:

any *.PSD file contain thees layers

semo5C92_0-1622302064691.png

 

Likes

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 Community Professional ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

 

open(fileList[a])

 

Likes

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
New Here ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

thank you bro, but i have other problem i need change color for hidden layers

and remove all layer not a TEXT

Likes

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 Community Professional ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

Hidden status of text layers doesn't prevent from changing their colour.

 

Remove all layer, which one, not text one? But which exact 'all' layer?

Likes

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
New Here ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

whell, it's change just first layer to green!

semo5C92_0-1622306550896.png

and other layers didn't change their colors what's wrong?

 

#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[a])

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

};

Likes

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
New Here ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

I want to remove all layers if they are not TEXT layers

Likes

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 Community Professional ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

Replace lines from 22 to 34 of your original code to:

 

(sc = SolidColor).rgb.hexValue = '00ff00', lrs = [].slice.call((aD = open(fileList[a])).layers)
while(lrs.length) (shft = lrs.shift()).kind == 'LayerKind.TEXT' ? shft.textItem.color = sc : shft.remove()

 

Likes

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
New Here ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

nice bro it's work fine! i need final request

i need delete custome layer by name

example:

if TEXT layer her name ( SEMO )

i want delete it only

Likes

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 Community Professional ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

LATEST

Instead of:

 

?

 

 put this code:

 

&& shft.name != 'SEMO' ?

 

btw if previous answer is what you wanted mark it as correct solution 😉

Likes

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