Scripting for InDesign indb files

Hi.

I’ve had no trouble running my script on a single IND file, but I would like to run it on my entire book at once- and am having no luck with syntax.

I have:

tell application “Adobe InDesign CS4”
activate
tell book “Book 1.indb”
tell document 1
try
set grouped_items to every group
repeat with ungroup_repeater from 1 to count grouped_items
ungroup grouped_items
end repeat
on error
–no grouped items found
end try

		set Text_Layer to make layer
		try
			set name of Text_Layer to "live copy"
		on error
			--name already exists
		end try
		
		
		
		try
			set text_frames to every text frame
			repeat with textframe_repeater from 1 to count text_frames
				move text_frames to layer "live copy"
			end repeat
			
		end try
		
		try
			set text_paths to every text path
			repeat with text_path_repeater from 1 to count text_paths
				move text_paths to layer "live copy"
			end repeat
		end try
	end tell
end tell

end tell

Which gives me a “can’t make class layer” error.

I’ve been trying to figure it since lunchtime. Seems like I’m missing something very simple…

Thanks in advance for any assistance.

You have to remember that Book files are really more like a list of links to documents, not unlike the Link pallette links to external image files.

So document-level changes need to be directed at specific documents in the Book (just as you’d have to edit linked images in their appropriate application). The only Book features that might be scriptable are items literally show in the Book pallette’s pop-up menu.

I teach InDesign, but I’ve not attempted to script it. I just figured that bit of background/perspective might help your thought processes.

I have never worked with books so I had to look into it. Basically you want to get the file list from the book, open each file and process it, and close with saving. A skeleton script for doing this follows:

tell application "Adobe InDesign CS3"
	tell book 1
		set fileList to full name of book contents
	end tell
	repeat with aFile in fileList
		set theDoc to open aFile
		
		--do stuff here to open document
		
		close theDoc saving yes
	end repeat
end tell