Last week’s blog was a quick overview for automating InCopy for a story-first InDesign workflow. We will now look at a few details that can be added to that script to manage how the text is imported from a file.
If you want to allow the user to determine the properties to be in effect when the text is imported, set the showing options property of the place method to true.
For our example script, this would be part of the placeStory handler:
on placeStory(textFileRef, docRef) tell application "Adobe InCopy CC 2014" set storyRef to story 1 of docRef tell insertion point 1 of storyRef place textFileRef showing options true end tell end tell end placeStory
On the other hand, you can have the script set the values as needed for the appropriate import options. Depending on the type of file being imported, these preferences can be part of one of the following:
These preferences are for the application, so once set will be applied to all documents thereafter. If your settings are only for the specific import, you may want to save the original settings, have the script set the properties as desired, and restore the original settings after the settings are used. However, if you will want the settings to be permanent, you may want a separate script to set the properties for the application and only override these settings as needed for specific needs.
For the most part, these settings are self-explanatory. There are only a few settings exposed for plain text files. On the other hand, the list of properties for Microsoft Word and RTF files is considerably longer. The following sample demonstrates:
activate set textFileRef to choose file with prompt "Select file for editing" set fileInfo to info for textFileRef if kind of fileInfo is "Plain Text Document" then setPlainTextPrefs() else if kind of fileInfo contains "Rich Text Document" or kind of fileInfo contains "Word" then setRTFPrefs() end if --included for testing; assumes document is open tell application "Adobe InCopy CC 2014" tell insertion point 1 of story 1 of document 1 place textFileRef end tell end tell --======== --HANDLERS --======== on setPlainTextPrefs() tell application "Adobe InCopy CC 2014" tell text import preferences --see dictionary for list of settings for this property set character set to UTF8 set convert spaces into tabs to false set spaces into tabs count to 5 set strip returns between lines to true set strip returns between paragraphs to true set use typographers quotes to true end tell end tell end setPlainTextPrefs
on setRTFPrefs() tell application "Adobe InCopy CC 2014" tell word RTF import preferences set convert bullets and numbers to text to true --can be none, page break or column break set convert page breaks to none set import endnotes to true set import footnotes to true set import index to false set import TOC to false set import unused styles to false set preserve graphics to false set preserve local overrides to true set preserve track changes to true set remove formatting to false --can be resolve clash use existing, resolve clashauto rename, and resolve clash use new set resolve character style clash to resolve clash use existing set resolve paragraph style clash to resolve clash use existing set use typographers quotes to true end tell end tell end setRTFPrefs
Notice how the type of file is detected prior to setting the preferences. The script is provided only as an example.
Refer to our script overview in last week’s blog. Add text import preferences as needed and see what a script can do for automating your text editing workflow. Next week we will take an in-depth look at scripts to clean the text of double spaces and other common problems.