InDesign Saving Problem

Hi:

I’ve got a strange problem. I need to scan thru a bunch of folders looking for InDesign files, then open each up and save them out again, overwriting the original file (I’m doing this because I have a third-party InDesign plug-in which writes a special thumbnail to the file upon saving which displays on our DAM system).

Here’s the code I have at the moment:

set inputFolder to choose folder
display dialog "This script will open and save all InDesign files in the specified folder."

tell application "Finder"
	set newFiles to (every file of entire contents of inputFolder whose name extension is "indd") as list
	set fileNum to (count of newFiles)
end tell

set i to 1

repeat while i is less than fileNum
	set filePath to (item i of newFiles) as text
	display dialog filePath
	tell application "Adobe InDesign CS5.5"
		set user interaction level of script preferences to never interact
		open item i of newFiles
		tell active document to save saving in filePath
		close active document
		set i to i + 1
		set user interaction level of script preferences to interact with all
	end tell
end repeat

I can’t get it to overwrite the original. I keep getting errors like:

error “Can’t get saving of "Macintosh HD:Users:jonathanhodges:Desktop:UBS_Collect_Samples:UBZ2169 HumanitarianBrochure:Comp:UBZ2169Envelope.indd".” number -1728 from saving of “Macintosh HD:Users:jonathanhodges:Desktop:UBS_Collect_Samples:UBZ2169 HumanitarianBrochure:Comp:UBZ2169Envelope.indd”

Tried changing filePath to an alias instead of text and that didn’t work. Tried the force save boolean. The problem seems that since there are no modifications to the file at the time of the save, it wants to do a save as and give me a dialog box which I don’t want.

Anyone have any ideas? Thanks.

–jon

Hi,

the finder is a sssssslllllllllllooooooooowwwwwww… helper. If possible → don’t use!

try like this:

set foundFilesArray to paragraphs of (do shell script "find " & quoted form of POSIX path of (choose folder) & " -name *.indd")
set counter to 0

repeat with i from 1 to count of foundFilesArray
	set filePath to (POSIX file (item i of foundFilesArray))
	tell application "Adobe InDesign CS5.5"
		try
			
			set user interaction level of script preferences to never interact
			open filePath
			save active document to filePath
			close active document
			set counter to counter + 1
			set user interaction level of script preferences to interact with all
		on error e
			set user interaction level of script preferences to interact with all
			display dialog e giving up after 3
		end try
	end tell
end repeat

display dialog (counter as text) & " files have been resaved."



Hope it’ll work

Hans:

You’re right – that little shell script is lightning compared to my original Finder routine.

I guess the problem with my original script was I needed the POSIX file name to save it back.

Works like a charm. Many thanks for the help and the timely response.

–jon

Please :slight_smile:

this line:
tell active document to save saving in filePath
was wrong.

You can see it in the Editor, where ‘saving’ is displayed as variable …

Have a good day :slight_smile:

P.S. mdfind may be even faster …