Page 1 of 1

Iterating the Layers and renaming

Posted: Fri Nov 01, 2019 3:47 pm
by Grrr1337
Hi everyone,
File->Scripts->Load Files into Stack... and I'm loading a bunch of .pdf files as layers into my newly created .psd -
Since the layers get names such as "LayerName.pdf",
I'm wondering how I would iterate over them and right-trim the ".pdf" from their name? (with JS preferably)

Re: Iterating the Layers and renaming

Posted: Sun Nov 03, 2019 10:58 am
by Kukurykus

Code: Select all

(function(){
	for(var i = 0, arg = arguments[0]; i < arg.length; i++) {
		if (arg[i].typename == 'LayerSet') this(arg[i].layers)
		else arg[i].name = String(arg[i].name.split(/\.pdf$/i))
	}
})(activeDocument.layers)
Check your Private Message please.