InDesign Scripts

Over the years, I’ve written a lot of small InDesign scripts to help me complete tasks more quickly and efficiently, both when laying out print books and prepping completed books for ebook conversion. Thanks to a combination of these scripts, I’ve been able to save myself countless hours on menial tasks that InDesign doesn’t let you automate as standard. I’ve included the scripts I thought might be of some use to others below, with descriptions on what they’re supposed to do (I’ve written many more, but they’re so specific to problems I’ve run into and my working setup that I can’t imagine they would be of any use to anyone else).

This scripts have been tested on both Windows and Mac, and should work for any InDesign version starting with the original CC release. Feel free to use, abuse, fix, amend, whatever.

Tools used:

  • Adobe InDesign
  • BBEdit

Languages employed:

  • Javascript

InDesign Scripts

AutoLink.jsx – A script that will attempt to automatically take any selected text and turn it into a hyperlink within InDesign, with an associated Hyperlink character style. It detects if the text is an email address (by basically looking for an @ symbol) and turns it into a mailto: link if necessary. It will also add ‘http://’ to the link if it’s not already present in the text. Obviously this doesn’t work if the text you’ve selected isn’t a website address. It’s not magic.

CheckInBounds.jsx – A script that runs through every page in the current document, and checks that every object is within the bounds of the page it’s found on. If it isn’t, the script resizes the frame of the object so that it is. This *also affects images that go out to the bleed*, because it was written for ebook creation, and ebooks abhor a bleed.

CheckInBoundsSelected.jsx – Basically the same as above, except it only checks the objects you currently have selected.

ClearOverride.jsx – A very basic script that just clears overrides on any text you currently have highlighted. This was mostly just created because it seems like it’s impossible to assign this action to a shortcut key without it being a script.

ClearTransformations.jsx – Another simple script that takes all selected objects and clears any transformations from them

ColumnDown.jsx – This script looks at the object you’ve currently got selected, and then reduces the amount of columns on that page by one. If you don’t have anything selected, it’ll do it to the ‘active page’, which is the last page currently visible in the window.

ColumnUp.jsx – Same as ColumnDown.jsx, except it increases the number of columns rather than decreases them.

ConformBaselines.jsx – This script looks at the baseline grid settings of the currently active InDesign document, and then applies them to every other currently open InDesign document. For some reason there’s seemingly no inbuilt way to sync baseline settings across documents in a book, so if a baseline changes mid-production it could be a hassle to change it everywhere. This was created to remedy that.

ConformToWidth.jsx – This script will resize any objects you have selected to a specified width – this width is set (in points) at the beginning of the script. It will also adjust the height of any resized objects so that they keep their aspect ratio. This is a useful shortcut if you have a standard recurring graphic type that will appear throughout a book at a set size – say, QR codes.

ConformToWidth⅓.jsx – The same as above, except it resizes the object to one third of the width of the document page. Useful for ebooks, probably not as useful for print.

ConformToWidth½.jsx – The same as above, except it resizes the object to one half of the width of the document page. Useful for ebooks, probably not as useful for print.

ConformToWidth.jsx – The same as above, except it resizes the object to two thirds of the width of the document page. Useful for ebooks, probably not as useful for print.

ConformToWidth¾.jsx – The same as above, except it resizes the object to three quarters of the width of the document page. Useful for ebooks, probably not as useful for print.

ConformToWidthFull.jsx – The same as above, except it resizes the object to the full width of the document page. Useful for ebooks, sometimes useful for print.

CopyNDelete.jsx – This script takes all selected text frames, copies the text out of them, and then deletes them, leaving the whole lot in your clipboard. This is useful for ebooks, where image captions often need to be integrated into the main body of the text.

EdgeCleaner.jsx – This script looks at the object(s) you’ve got selected, and checks to see if its frame extends further than the graphics that’s contained within it (thereby leaving a transparent space between the edge of the graphic, and the edge of the frame). If it does, it reduces the size of the frame so that it meets the edge of the graphic. Useful generally, but particularly in ebooks, where transparent space will render out as excess blank white space in exported images.

FindChangeSubset.jsx – This script allows you to search for text, and then apply a character style to onky a subset of that found text. Useful for find and replace tasks where you only need to change part of the found text’s style.

FitObject.jsx – This script tries to make your pages nice and neat, by fitting your selected objects to their nearest margins/baselines. I believe this won’t work if you’re using InDesign’s fluid layouts, as it doesn’t seem to be able to see columns in those instances. BUT it does work with bleeds. BUT it doesn’t work over double page spreads. So, swings and roundabouts.

FullPage.jsx – This is a nice and simple script that just resizes a selected frame to take up the full size of the current page, not counting the bleed. A simple time-saving shortcut for ebook creation, but maybe useful elsewhere? Who knows.

MoveToNextPage.jsx – This script moves all selected objects to the next page of the current document. *However*, this was used pretty much exclusively on single-page ebook spreads, so I’m not sure how it acts on double-page spread documents. A rare element of mystery in your InDesign scripts.

MoveToPasteBoardLeft.jsx – This script moves every selected object left by a little more than the page width. Because it was made for ebooks, that would generally be the pasteboard, hence the name, but it works just as well on double-page spreads.

MoveToPasteBoardRight.jsx – Same as above, except it moves the objects to the right-hand pasteboard rather than left.

MoveToPreviousPage.jsx – Same as MoveToNextPage.jsx, except it moves them to the previous page. Again, not sure if it works on double page spreads.

RemoveWrap.jsx – This script removes text wrap from all selected objects, mostly so you can easily set that to a shortcut key.

RemoveWrapAll.jsx – This script runs through the entire active document and removes the text wrap from every object. That means EVERY OBJECT, unless it’s on a master page or is locked, so don’t use this unless it’s something you want to happen.

ReverseStackingOrder.jsx – This script is useful when importing a bunch of images into InDesign at once; by default you’ll be left with a stack of images where the first image you imported (likely the one you need first) will be at the very bottom. This script just reverses the stacking order of all selected objects so that it’ll be on the top.

RichardLinkalter.jsx – This is a complicated niche script to solve a complicated niche problem. Ebooks, being basically just packaged up webpages, don’t always play nicely with images that have weird spaces or punctuation in their names, because the references to the images will be turned into XHTML links and such. As such, it’s good practice to rename any images you’re going to use in an ebook to remove any spaces/punctuation/what have you. However, by doing that, you’ll naturally break any existing links in your InDesign documents, and InDesign doesn’t know how to automatically find those links again, because the names have changed. This lets you tell InDesign how the image names have changed (say, tell it that all spaces have been turned into underscores), and it will go through and relink everything for you. Like I said, a very specific problem, but this script has saved me dozens and dozens of monotonous hours fixing broken InDesign links. It also has a fun name.

SkewDetector.jsx – Probably a problem that only I ran into, but when converting old books into ebooks, it’s often the case that rather than using a proper style for italic text, the original book designer just used a random skew degree on the text, and this degree could change from one sentence to the next. This script finds all text with any skew other than 0° and marks up in bold and red to draw your attention to it, and allow you to give it a real character style.

TextFrameColumnDown.jsx – Much the same as the ColumnDown.jsx script, except it does it to the currently selected text frame, rather than the page as a whole.

TextFrameColumnUp.jsx – Much the same as the ColumnUp.jsx script, except it does it to the currently selected text frame, rather than the page as a whole.

UnlockAll.jsx – This script unlocks every single object in the current InDesign document. This is useful for situations where you want to unlock every single object in the current InDesign document