Your prescription for increased productivity and profitability
When it comes to creating a new document in InDesign, there are three main methods one can use:
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:
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.
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
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; } } }
Once the user has identified the name of the template to use (templateName), the document is created:
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
var appPath = app.filePath; var templatePath = appPath + "/Templates/" + templateName; var docRef = app.open(File(templatePath));
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:
set homePath to (path to home folder from user domain) as string set publicPath to homePath & "Dropbox"
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:
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
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
Once the script verifies folders needed exist, the document is saved. Adding a label to the document provides another means for identification.
set filePath to projectPath & ":" & projectName & ".indd" tell application "Adobe InDesign CC" set label of docRef to projectName save docRef to filePath end tell
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.