Unlock and delete only Template Layers

Surely there must be a way to unlock (every layer whose dim placed images is equal to true and printable is equal to false)?

My goal is to delete only those specialty “Template Layers”
I figured out how to delete only those template layers but only after attaching Jim’s script which unlocks “all layers” above it.

It would be nice for other layers that were locked to remain locked.

Can anyone help me out?
-jeff

tell document 1 of application "Illustrator CS"
	activate
	set topLevelLayers to (every layer whose class of container is document)
	repeat with thisLayer in topLevelLayers
		my unlockLayers(thisLayer)
	end repeat
	if ((count of page items) > 0) then set locked of every page item to false
end tell

on unlockLayers(thisLayer)
	tell document 1 of application "Illustrator CS"
		set locked of thisLayer to false
		set subLevelLayers to (every layer of thisLayer)
		repeat with thisLayer in subLevelLayers
			my unlockLayers(thisLayer)
		end repeat
	end tell
end unlockLayers
tell document 1 of application "Illustrator CS"
	activate
	
	set deleteLayer to (every layer whose dim placed images is equal to true and printable is equal to false)
	try
		delete deleteLayer
	end try
end tell

This script seems to be working only on those conditions where the layers are dimmed and non printing.
But then again I can’t believe I got a script to work? Someone will probably find something wrong :frowning:

tell document 1 of application "Illustrator CS"
	activate
	
	set deleteLayer to (every layer whose dim placed images is equal to true and printable is equal to false)
	
	try
		set locked of (every layer whose dim placed images is equal to true and printable is equal to false) to false
	end try
	
	try
		delete deleteLayer
	end try
end tell