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

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

New Here ,
May 29, 2021 May 29, 2021

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
1.8K
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

LEGEND , 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()

 

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

note:

any *.PSD file contain thees layers

semo5C92_0-1622302064691.png

 

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

 

open(fileList[a])

 

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

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

and remove all layer not a TEXT

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

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?

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

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

};
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 ,
May 29, 2021 May 29, 2021

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

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 ,
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()

 

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

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

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

Instead of:

 

?

 

 put this code:

 

&& shft.name != 'SEMO' ?

 

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

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