InDesign: Exporting IDML file in the Package Folder

Hi,

I have an script edited by myself to create a package and an IDML file from an open document.
The script is working fine and is creating a package and an IDML as expected. There is just a very slight problem in this script.

The exported IDMl is saving in the Parent folder, whereas I want the IDMl in the package folder, rather than moving it manually. So that I can just zip the package folder (containing the idml and send it to my colleagues.

In the script below, the sourceName is being considered as the folder name for the creation of a package. Similarly I would like to save my idml in the sourceName folder.

How can I define souceName as a folder, so that I can use it for other purposes as well

Any help :slight_smile:

tell application "Adobe InDesign CS5"
	set myDocument to active document
	set docName to name of myDocument
	set sourceName to text 1 thru -6 of docName
	set sourcePath to the file path of myDocument
	tell document 1
		package to alias (sourcePath & sourceName 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 no
		
		set idmlFile to (sourcePath as string) & sourceName & ".idml"
		
		export myDocument format InDesign markup to file idmlFile
		
		--close saving no
	end tell
end tell

hi
give Shane’s code a try from this thread

http://macscripter.net/viewtopic.php?id=41338

Thanks Budgie, however, I tried it a different way and is working fine:

Here is the revised script:


tell application "Adobe InDesign CS5"
	set myDocument to active document
	set docName to name of myDocument
	set sourceName to text 1 thru -6 of docName
	set sourcePath to the file path of myDocument
	
	tell application "Finder"
		set packFolder to make new folder at sourcePath with properties {name:sourceName}
	end tell
	
	tell document 1
		package to alias (sourcePath & sourceName 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 no
		
		set idmlFile to (sourcePath as string) & sourceName & ".idml"
		
		export myDocument format InDesign markup to file idmlFile
		
		--close saving no
	end tell
end tell


I have two more questions that are part of this script:

  1. How to group all objects on a page and then align them to page with Vertically-Center and Horizontally-Bottom options. I’m using InDesign CS5 and CC

Somehow, I got these codes, they are grouping all the elements on my page

set theItems to active spread of layout window 1
		make group at theItems with data {group items:every page item of theItems}
  1. In my script for creating package and idml, I can reach to the Source Folder containing the InDesign file:
set sourcePath to the file path of myDocument

but how can I reach to the folder containing the Source Folder, For example:

Let’s assume the File structure is:

Folder1 > Folder2 > Folder3 > TestFile.indd

with the help of the above command I can reach to “Folder3” as it is the Source Folder of my InDesign file, similarly How can I reach to “Folder2” and “Folder1”

Any help is much appreciated

Hi
I think this might answer question1, the code groups all items and then centers them on the page

tell application "Adobe InDesign CC"
	activate
	set {a, b, c, d} to bounds of page 1 of document 1
	(*  -- Can use this for specific layer
	try
		set mylayer to "TEST"
		set active layer of active window to mylayer
	end try
	*)
	set myDoc to active document
	set mySel to page items of myDoc
	tell myDoc
		set MyNewSel to make group with properties {group items:mySel}
		set {w, x, y, z} to geometric bounds of result
		move MyNewSel by {(d / 2 - (x + z) / 2), (c / 2 - (w + y) / 2)}
	end tell
end tell