InDesign tip : #16

there appears to be no shortage of ingenious ways that InDesign users can make life difficult for themselves. here’s a cracker…

sometimes you need to indent a paragraph to accommodate a graphic, or a drop cap, or whatever. like this :
screen grab showing indented paragraph

this is the way NOT to do it. not only is it time consuming to set up — it’s a pain in the bollocks if you need to edit the text later :
screen grab of wrong way to align a paragraph

here’s one correct way to do it — set the left indent to the same as the tab and set the first line indent to its equivalent negative :
screen grab of paragraph aligned using correct text indents
screen grab showing the indets in the control panel

the only drawback of that method is that if you decide to change the tab later on, you also have to remember to change the two indents to match.

the other method is the best of all worlds — easy to set up and easy to edit :
screen grab showing the use of the 'indent to here' character

the indent to here character looks a bit like a sword (or a cross, if you prefer). place the character in the position where you want your paragraph to align to by using command-\. now if you decide to change the tab, the rest of the paragraph moves automatically.

if you think placing a whole bunch of those little doovies in a whole bunch of paragraphs is too time-consuming, then you really should revisit tip #15.

try it — you’ll like it.

macgrunt icon

InDesign scripting : lesson 18

ok — that’s enough lollygaggin’ around. let’s get back into it with a simple one. here’s how to shorten a filepath.

way back in lesson 12 you saw how to save a pdf into the same folder as your InDesign file (that script actually created a subfolder to contain the pdf — keeping everything nice and neat).

but sometimes you may want to go further UP the folder hierarchy. so, for example, if your InDesign file is here :

MacGrunt > Users > ThisUser > Documents > InDesign Files > TheDoc.indd

rather than accessing the folder containing the file — “InDesign Files” — you want to access the next one up — “Documents”. here’s how.

you get the file path of an InDesign document like this :

tell application "Adobe InDesign CS4"
  set theFilepath to file path of active document as string
end tell
return theFilepath

resulting in a string like this :

"MacGrunt:Users:ThisUser:Documents:InDesign Files:"

using text item delimiters, we can get the separate parts of that path :

set text item delimiters of AppleScript to {":"}
set theFilepathBits to text items of theFilepath
set text item delimiters of AppleScript to ""
return theFilepathBits

resulting in a list of elements :

{"MacGrunt", "Users", "ThisUser", "Documents", "InDesign Files", ""}

notice the end of the list is an empty item. no doubt some Applescript guru can explain why that happens.

we can then join the relevant bits back together :

set text item delimiters of AppleScript to ":"
set newFilepath to text items 1 thru 4 of theFilepath as string
set text item delimiters of AppleScript to ""
return newFilepath

giving us the string we’re looking for :

"MacGrunt:Users:ThisUser:Documents:"

now, that’s only going to work if your InDesign files are always six levels down in the hierarchy. but what we really want is a way to access the folder that’s one above the InDesign file no matter how deeply the file is buried.

luckily Applescript also lets you count backwards through a list. so, in the above example, “” is text item -1, “InDesign Files” is text item -2, etc.

so, what we need is this :

tell application "Adobe InDesign CS4"
  set theFilepath to file path of active document as string
end tell
set text item delimiters of AppleScript to ":"
set newFilepath to text items 1 thru -3 of theFilepath as string
set text item delimiters of AppleScript to ""
return newFilepath

that’s it — pretty simple, but pretty handy. with this little trick up your sleeve you’ll be throwing files all over the place with Applescript now.

keep grunting.

macgrunt icon