Create a Document for InCopy Workflow

When it comes to creating a new document in InDesign, there are three main methods one can use:

  1. Start from Scratch – Select New from InDesign’s File Menu then define the properties for the document in the New Document window: page size, intent, margins, and so on. Identify type styles, object styles, and styles for tables. This is the most versatile method but most costly in terms of time.
  2. Start with Presets – A document preset can define all of the properties for the document. Once the document framework is constructed, import styles from stylesheets and/or other documents. This provides a little more efficiency but is still quite time consuming.
  3. Start with a Template – A template defines every aspect of the document including styles and possibly page layouts. This is the most efficient method, but does not provide for much versatility.

Of course, you can add a script or two to any of the above methods to increase efficiency. For instance, to start a document using a template a script could:

  • present the user with a list of templates from which to choose
  • create the document using the template identified by the user
  • provide a text field in which the user can give the document and/or project a name
  • make sure the folder in which the document is to be saved has the correct structure
  • save the document once created using the name provided by the user

Present List of Templates

By default, the path to the Templates folder is in the Applications folder for InDesign. The following will return a list of file names found in that folder. It provides a test on the list to only return names of files having an “.indt” extension.

AppleScript

set templateList to {}
--create path to Templates folder
tell application "Adobe InDesign CC"
     set appPath to file path as string
end tell
set templatePath to appPath & "Templates:"
--get list of template references 
set templateNames to list folder templatePath without invisibles
--repeat through list and add names of files ending in .indt to templateList
repeat with i from 1 to length of templateNames
     if item i of templateNames contains ".indt" then
          set end of templateList to item i of templateNames
     end if
end repeat

ExtendScript

The code for ExtendScript is a little more involved because it has to work for both Windows and Macintosh.

var appPath = app.filePath;
var templatePath = appPath + "/Templates";
var templateNames = listFiles(templatePath);
templateNames;
function listFiles (templatePath) {
    var nameArr = [];
    var folderRef = Folder(templatePath);
    //determine system script is running on
    if (File.fs == "Windows") {
        var fileList = folderRef.getFiles("*.indt");
    } else {
         var fileList = folderRef.getFiles(listIndt);
    }
     //repeat through list and return names of files having .indt extension
     for (var i = 0; i < filelist.length; i++){
          nameArr.push(File.decode(fileList[i].name));
     }
     return nameArr;
     /*filter function for Macintosh checks for "indt" extension*/
     function listIndt(objRef){
          if (objRef instanceof File) {
               return objRef.name.toUpperCase().indexOf(".INDT") != -1;
          }
     }
}

Create Document from Template

Once the user has identified the name of the template to use (templateName), the document is created:

AppleScript

tell application "Adobe InDesign CC"
     set appPath to file path as string
     set templatePath to appPath & "Templates:" & templateName
     set docRef to open file (templatePath)
end tell

ExtendScript

var appPath = app.filePath;
var templatePath = appPath + "/Templates/" + templateName;
var docRef = app.open(File(templatePath));

Verify Folder Structure

For a project involving an InCopy workflow, the shared folder in which the document is to be saved needs to include an assignments folder. The assignments folder also contains a folder named “content”.

To illustrate, the path to the shared folder could be a folder named “Dropbox” residing in the user’s home folder:

AppleScript

set homePath to (path to home folder from user domain) as string
set publicPath to homePath & "Dropbox"

ExtendScript

var publicPath = Folder("~/Dropbox");

From there, given the name for the project and a reference to the document created from the template, a series of tests can be directed to the system in which the folder is created if it does not exist:

AppleScript

set homePath to (path to home folder from user domain) as string
set publicPath to homePath & "Dropbox"
set sharedName to "Test Project" --could be defined by user as part of custom dialog
set projectPath to publicPath & ":" & sharedName
tell application "Finder"
if not (exists folder projectPath) then
     make folder at folder publicPath with properties {name: sharedName}
end if
--and so on
end tell

ExtendScript

var publicPath = Folder("~/Dropbox");
var sharedName = "Test Project";
var projectPath = publicPath + "/" + sharedName;
if (Folder(projectPath.exists == false) ){
        Folder (projectPath).create();
}
//do similar for other folders in structure

Save Document

Once the script verifies folders needed exist, the document is saved. Adding a label to the document provides another means for identification.

AppleScript

set filePath to projectPath & ":" & projectName & ".indd"
tell application "Adobe InDesign CC"
     set label of docRef to projectName
     save docRef to filePath
end tell

ExtendScript

var filePath = projectPath + "/" + projectName + ".indd";
docRef.label = projectName;
docRef.save(new File(filePath));

For the complete script, download from either our AppleScript page or ExtendScript page.