Show all layers of all files in the folder

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

nghiank09
Posts: 3
Joined: Fri Apr 02, 2021 3:26 pm

Show all layers of all files in the folder

Post by nghiank09 »

Hello,
I'm trying to show all layers of all files(.psd) in the folder. The process will be like that:
Step 1: Open the first file
Step 2: Select all layer of this file
Step 3: Show all layer of this file
Step 4: Save and close
Step 5: Open the second file
Step 6: Select all layer of this file
Step 7: ...
Thanks a lot for your help.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Show all layers of all files in the folder

Post by Kukurykus »

Code: Select all

sTT = stringIDToTypeID, fls = File('~/desktop/Folder/')
.getFiles('*.psd'), dsc = new ActionDescriptor(); while(fls.length) {
	if ((lrs = (actvDcmnt = open(fls.shift())).layers).length > 1 || !lrs[0].isBackgroundLayer)
		runMenuItem(sTT('selectAllLayers')), (ref = new ActionReference()).putEnumerated
		(sTT('layer'), sTT('ordinal'), sTT('targetEnum')), (lst = new ActionList()).putReference(ref),
		dsc.putList(sTT('null'), lst), executeAction(sTT('show'), dsc); actvDcmnt.save(), actvDcmnt.close()
}
nghiank09
Posts: 3
Joined: Fri Apr 02, 2021 3:26 pm

Re: Show all layers of all files in the folder

Post by nghiank09 »

Kukurykus wrote: Tue Apr 06, 2021 1:21 pm

Code: Select all

sTT = stringIDToTypeID, fls = File('~/desktop/Folder/')
.getFiles('*.psd'), dsc = new ActionDescriptor(); while(fls.length) {
	if ((lrs = (actvDcmnt = open(fls.shift())).layers).length > 1 || !lrs[0].isBackgroundLayer)
		runMenuItem(sTT('selectAllLayers')), (ref = new ActionReference()).putEnumerated
		(sTT('layer'), sTT('ordinal'), sTT('targetEnum')), (lst = new ActionList()).putReference(ref),
		dsc.putList(sTT('null'), lst), executeAction(sTT('show'), dsc); actvDcmnt.save(), actvDcmnt.close()
}
Thanks for your help!!!
I open PS CS6, then File/Script/Browse ... I choose your code, then a notification appears

Error 24:File().getFiles is not a function.
line: 1
-> sTT = stringIDToTypeID, fls = File('E:\1. PHAP TIEN DNT TAP 38\4. Tô màu_full/')

I'm so sorry, I just a beginner. Could you give me more instructions, plz
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Show all layers of all files in the folder

Post by Kukurykus »

Remove colon and change backslashes to slashes, plus add one at beginning of path.
nghiank09
Posts: 3
Joined: Fri Apr 02, 2021 3:26 pm

Re: Show all layers of all files in the folder

Post by nghiank09 »

Kukurykus wrote: Tue Apr 06, 2021 2:19 pm Remove colon and change backslashes to slashes, plus add one at beginning of path.
I keep the colon and change backslashes to slashes, the code works very effectively. You are awesome.