need to delete the Layer in indesign

Hi Team,

Here is the script for delete the layer for a single document, but i need to 100 indesign documents in a folder how it is possible.

tell application “Adobe InDesign CS2”
set myDocument to active document
tell myDocument
delete (every layer of myDocument whose name is “Graphics”)
end tell
end tell
display dialog "Graphics layers was deleted "

—Gopala

Hi,

try this


set theFolder to choose folder
tell application "Finder" to set theFiles to files of theFolder whose name extension is "indd"
repeat with oneFile in theFiles
	tell application "Adobe InDesign CS3"
		set myDocument to open (oneFile as alias)
		tell myDocument
			delete (every layer whose name is "Graphics")
		end tell
		close myDocument saving yes
	end tell
end repeat
display dialog "Graphics layers were deleted "


Thank u so much StefanK, Let you know still i have any problems on the same.

I have basic AS experience. Similar task going to a folder, open ID docs, delete layer, save & close but the script stops because there is some docs that the layer I want to delete “SOnic” is not present. Im getting error:

error “Adobe InDesign CS4 got an error: Can’t get every layer of document 1 whose name = "SOnic".” number -1728 from every layer of document 1 whose name = “SOnic”

What is the proper line code to ignore if the layer is not found then ignore. See below.

set source_folder to choose folder with prompt "Select folder containing InDesign docs to Delete SOnic layer." with multiple selections allowed without invisibles

tell application "Finder" to set item_list to (every item where name ends with "indd") of folder source_folder as alias list

tell application "Adobe InDesign CS4"
	activate
	repeat with DocAlias in item_list
		set doc to open DocAlias --without showing window ignore any dialogs
		tell document 1
			delete (every layer whose name is "SOnic")
		end tell
		
		save doc
		delay 3
		close doc
	end repeat
end tell

beep 3
with timeout of 10000 seconds
	tell application "Finder"
		activate
		display dialog "SOnic layer has been deleted :-)" buttons {"OK"} default button 1
	end tell

end timeout

check if the layer exists


.
if exists layer "SOnic" then delete (every layer whose name is "SOnic")
.