Indesign "Save as" Skript

Hi everyone,

When working with Indesign CS2 you sometimes have to save your Document with “Save as” otherwise these Documents will grow permanently in file size since ID CS2 doesn’t clean up its own files very well.

Instead of opening and “saving as” hundrets of documents on our server i decided to write an applescript for that. So far - so good.

My only problem ist that my skript crashes Indesign if the Document is very large (more than 20 MB). Smaller files are no problem…

Here is my Script:


property type_list : {"indd"}
property extension_list : {"indd"}

on run
	display dialog "Save Indesign Documents again for smaller file-sizes" buttons {"OK"} default button 1 with icon (path to resource "dockling.icns" in bundle ((path to library folder from system domain as string) & "CoreServices:dock.app") as alias)
end run

on open these_items
	tell application "Adobe InDesign CS2"
		set user interaction level of script preferences to never interact
	end tell
	
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			process_item(this_item)
		end if
	end repeat
	
	tell application "Adobe InDesign CS2"
		set user interaction level of script preferences to interact with all
	end tell
	
	activate
	display dialog "All Files have been saved." buttons {"OK"} default button 1 with icon (path to resource "AlertNoteIcon.icns" in bundle ((path to library folder from system domain as string) & "CoreServices:CoreTypes.bundle") as alias)
end open

on process_folder(this_folder)
	set these_items to list folder this_folder without invisibles
	repeat with i from 1 to count of these_items
		set this_item to alias ((this_folder as text) & (item i of these_items))
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) and ¬
			((the file type of the item_info is in the type_list) or ¬
				the name extension of the item_info is in the extension_list) then
			process_item(this_item)
		end if
	end repeat
end process_folder

on process_item(this_item)
	tell application "Adobe InDesign CS2"
		activate
		open (this_item)
		delay 1
		save document 1 to (this_item as string) & "#"
		close document 1 saving no
	end tell
end process_item

What am i doing wrong? Any Ideas?

Greetings
Sebman

Model: Dual G5 - 2Ghz
AppleScript: 1.10.7
Browser: Firefox 2.0.0.1
Operating System: Mac OS X (10.4)

I’m betting Adam, Bruce, Stef etc… will come in with a logical answer before me, but ther is another way beside “Save as” though it is essentially the same thing.

You can export the document in the InDesign Interchange (INX) format. This strips out a lot of the junk and preview images that InDesign generates greatly reducing the file size in most cases. It also is a great tool when working with corrupt docs.

Hi James,

i can’t use the INX Format for one simple reason:
All Linked images are not on the server anymore. Only the ID-Documents stay on the Server for Quick Reference and in order to re-use certain layout Objects. If i would export the Document as INX all Previews would be lost since the Linked images aren’t available any more - which is bad.

“Save as” does the job pretty well - nailing down a 50 MB Doc to 5 MB without loosing the Previews is exactly what i need. But somehow my script kills ID - especially when the Documents are very large.

But thanks for the tip - actually i didn’t even know that this Format exists…

Greeting
Sebman