Adobe InDesign CS4, Sorting with Scripts.
This is the second part of a two part write-up about sorting paragraph and table text in InDesign and covers the sorting of table data, thanks to a great script developed and provided freely by Peter Kahrel.
Sorting Table Columns
Sorting Table data is not something the SortParagraphs.jsx script that comes installed as a Sample script in InDesig does. Unless you first convert the Table to Text, then sort based on the ‘first column’ and recreate the table. However, if the table has already been created and been nicely designed that might not be an option. In addition, you could only sort on the first column in that case… and not choose to sort on another column.
Peter Kahrel, UK-based InDesign Scripter extraordinaire has been kind enough to release a free script that allows you to sort table data, amongst a myriad of other scripts.
Sort Tables script from Peter Kahrel.
This might be the first time you’ve gone through the steps of downloading a script for use in InDesign. I’ll take you through the process of downloading and installing the script in InDesign. Believe me it’s a pretty painless process.
To download the script from Peter Kahrel’s site, Right-click the Show Script button. Depending on which browser you’re in the contextual menu that appears might be a little different. I’m using Mozilla Firefox here, and this has a Save Link As… option.
The Save Dialog Appears. At this stage, I’ll just save the script SortTable.jsx to the Desktop. Your browser might download into a Downloads folder.
How to install scripts in InDesign
We’re now ready to install the script so we can run it from within InDesign, but must first install it. InDesign Scripts can be installed in two different locations:
- At Application level, which makes the Script accessible to all users on the workstation. E.g. regardless of which user account is used upon startup
- At User level, which makes the Script accessible only to the current active user.
If you’re into sharing Scripts with your mates who use the computer on which you’re installing the script, than install at Application level!
Ensure the Script Panel is visible (Window > Automation > Scripts).
Click the Application folder in the scripts panel, then from the panel menu choose Reveal in Finder (on Windows this will say Reveal in Explorer), alternatively right-click the Application folder
The Scripts Panel folder inside the InDesign application folder on your computer is selected. Double click this folder to open it.
You’ll notice that this is the folder that contains the Apple and Java samples Scripts 🙂
The folder hierarchy you see here is identical to what you see in the Scripts panel. If you want to organise your scripts a little you can create additional folders inside the Scripts Panel directory. I’m adding a folder called myOtherScripts.
Next copy the previously downloaded script into the Scripts panel folder (or sub-directory there-of).
Time to check if the Script is now visible in InDesign (there is no need to relaunch InDesign when you add a script).
That’s it we’re now ready to start sorting some table data. The script allows you to either sort a particular range of data, or all of the table data.
- To sort based on data range, highlight some cell data in the column that is the trigger for the sort order you want to generate
- To sort the entire table, simply insert your cursor anywhere in the column that is the trigger for the sort order.
In my example I want to sort the entire table, based on the data in the very first column. So I use my Type Tool and click in one of the cells in the first column.
Next it is time to run the script. This time I’m double clicking the script in the Scripts panel (to learn more about running scripts refer to the first part of this 2-part “Sort it please…” series.
I’m placing my cursor in one first body cell of the first column (“Road with Pollard…”), and going for the Double Click to run the script option.
Running the tablesort.jsx script triggers a dialog prompt that asks for some input.
I’ll be sorting in Ascending order (A-Z) and my data is alphanumberical (combination of numerical and alphabetical characters). The script is smart enough to pick up that the Table I’m sorting contains a Header Row.
For a detailed write-up of the script functionality, please refer to Peter Kahrels accompanying post to the Script.
http://www.kahrel.plus.com/indesign/tablesort.html
Once the Table Sort Options are set, click OK… and wait a little while (long tables might take some seconds to fully complete their sorting).
and ta-daaaahhh… one beautifully sorted table…
A special thank you goes out to Peter Kahrel, who’s made this script available to us InDesign lovers! Thank you Peter!
You absolutely rock, Cari. THANK YOU!
Thanks! This saved me hours of work…!
Always nice to hear my tips help improve productivity. Thanks Joakim 🙂