Package Indesign Document - Applescript

Hi

Can anyone tell me if there is a way to script the packaging of a document in applescript?

many thanks

LJ

this works:



set collectMac to "MrComputer:WamX:" & jobNameHere -- path to collected file and name

tell application "Adobe InDesign CS3"
	activate
	tell document 1
		package to collectMac copying fonts yes copying linked graphics yes copying profiles no updating graphics no ignore preflight errors yes creating report yes 
		close saving no
	end tell
end tell

cheers,

Ralph

Hello,
This is a pretty old post, but did anyone ever figure out how to set up the entire process. This could be really usful. Sometimes I collect many jobs at once and it would certainly save from the redundancy?
Thanks
babs

that is the entire process.

if you want to iterate of a number of files in a folder:


set f to choose folder

tell application "Finder"
    set myFiles to (files of entire contents of f whose name extension is indd) as alias list
end tell

repeat with aFile in myFiles

(put above code here)

end repeat

I don’t have my mac here to test this on but it’s pretty close to what you need.

-RL

Hi Ralph!
Thanks for getting back to me so quickly!!

This is what I did:


set f to choose folder

tell application "Finder"
	set myFiles to (files of entire contents of f whose name extension is indd) as alias list
end tell

repeat with aFile in myFiles
	
	tell application "Adobe InDesign CS5.5"
		activate
		tell document 1
			package to collectMac copying fonts yes copying linked graphics yes copying profiles no updating graphics no ignore preflight errors yes creating report yes
			close saving no
		end tell
	end tell
	
end repeat

It does ask me for the folder with the InDesign documents, but then I get this message:

“the variable indd is not defined” (and it highlights indd in the line that starts with , set my files to…)

any thoughts?
thanks so much!
babs

wrap it in quotes and it’s a string. “indd”

Hi Mark,

Getting closer!!

Next error-in the tell document 1 statement, package to collectMac
The variable collectMac is not defined???

I kind of know what that means, but I am not sure how to go about defining it?
if you can give me any guidance, I would really appreciate it!

thanks
babs

did you define it?

set collectMac to "MrComputer:WamX:" & jobNameHere -- path to collected file and name

naturally you need to change the path to your own particular computer and file structure. you’ll also need to assign jobNameHere a value, which you can harvest from the file name as you iterate through them.

HI Ralph,
no, I didn’t…gonna look at some old scripts and try to figure out!!!
thanks for putting me in the right direction!
babs

Try this, it should work. Please note that each package will end up having it’s own folder:

set f to choose folder with prompt "Choose your source InDesign folder"
set collectMac to choose folder with prompt "Choose where you want to package your InDesign documents"
tell application "Finder"
	set myFiles to (files of entire contents of f whose name extension is "indd") as alias list
end tell
repeat with aFile in myFiles
	tell application "Finder"
		set package_folder_name to characters 1 thru -6 of (get name of aFile) & " Folder" as string
		make new folder at collectMac with properties {name:package_folder_name}
	end tell
	tell application "Adobe InDesign CS5.5"
		activate
		open aFile
		tell document 1
			package to alias (collectMac & package_folder_name as string) copying fonts yes copying linked graphics yes including hidden layers yes copying profiles no updating graphics no ignore preflight errors yes creating report yes
			close saving no
		end tell
	end tell
end repeat

Hello Stefcyr,

That worked perfectly!

I was working on it for some time, and I can see where I have difficulty.
I have been pulling your code apart piece by piece and it is very clearly written for me to understand. I can see where I was making most of my mistakes…

I do have a question with the file name it makes for the folder.

	
	set package_folder_name to characters 1 thru -6 of (get name of aFile) & " Folder" as string

I do not understand what the 1 thru -6 means? how does that work with the file name? This is where I really was messing up, as I didn’t set a variable for the file name at all, my first mistake, and I would have just tried to figure out how to get the name, but I never would have figured this out?

Everything else makes perfect sense!!! :smiley: :smiley: :smiley:

thank you!
babs

If the InDesign document’s name is “My Indesign document.indd”, the line characters 1 thru -6 of “My Indesign document.indd” as string (as string is important here or you’ll get a list such as {“M”, “y”, " ", “I”, “n”, “d”, “e”, “s”, “i”, “g”, “n”, " ", “d”, “o”, “c”, “u”, “m”, “e”, “n”, “t”}) returns “My Indesign document”, skipping the last 5 characters thus preserving the file name without the “.indd” extension to use for the package folder name. In that script, I use the Finder to get the file name because using InDesign to get the file name will not work if you open a document that’s been created with an older version of InDesign (you get the [converted] beside de document name on the InDesign window).

ahhhh…makes sense!
Thanks for clarifying that.
Again…thank you!
babs

Hi,
I was a bit curious why you chose the Finder for the rename, rather than IND, but now that you explained it, that makes sense.
Thank you for the extra edit to the explanation on the 1 through -6 (I was taking it as .indd (5 characters) and the -6 just means it included it ending the name at that point. My mind would have said -5, but again, I can see it needs to count that last character (-6 slot),

babs!!

This is exactly what I was looking for, Thanks guys.

In my folder setup I have a “Prelim” folder is there anyway to exclude this folder and its files from being packaged?

Thanks.