I love to make machines do my work for me, and I like to share ideas so that others can consider the possibilities of working smarter. The titles on the descriptions below are links to pages outlining some of the things I have learned. These pages provide commented AppleScript workhorse routines that should be of use in all kinds of projects and should migrate well to various word processing applications. These were written for a program called NewsEdit from MediaSpan Media Software, but only a few lines of each would need to be modified to work in other applications. Most of them started as Apple-supplied routines for Finder tasks. Each entry includes suggested enhancements that might be useful and should be simple to script, even for newbies. Nowadays, with Apple’s Automator, development should be easier still.
These samples are guides to basic scripting and the author will not be held liable for any damages arising from their use. The code is presented so that it can be copied and pasted into a Script Editor window, but as with any copy and paste, you should check for unintended line breaks or mistranslated special characters. Some of the lines may be longer than the browser window, so you may want to stretch it to check. In my own projects, most of my scripts make copies of source files and work on the copies. I generally turn automation loose only on duplicates. These sample routines are running on Mac OS X, through version 10.4.
Purpose: Save time and trouble with a few tips on traps to avoid in your scripting. Sad to say I learned about most of them the hard way in years of refining my scripts.
Purpose: Change case of selected text to all upper, all lower, cap first letter of each word. Most word processing programs provide some sort of facility to do this, but this combines multiple options in one window and the general technique may be used to alter other text attributes.
Operates on: A selection in the frontmost editing window.
Purpose: Parse data in a delimited text file and reformat.
Operates on: Story in the frontmost editing window.
Suggested uses: Pliable script can be customized in short order for converting any statistical material into plain-English format, with string manipulation, date conversion, calculations and rearrangement of fields. Turn spreadsheet or database records into print listings and encode specialized typography as needed.
Purpose: Performs multiple search and replace from a list of standard search-replace pairs (useful for style enforcement or translation from outside sources).
Operates on: Full text of the frontmost editing window.
Suggested uses: Any material that takes repetitive cleanup, such as horoscopes, bridge columns, sports statistics, court filings, bankruptcy listings. Expansion or abbreviation in addresses: Road to Rd., Avenue to Ave. Style cleanup: AM or PM to a.m. or p.m. Removing zeros from times: :00 p.m. to p.m.