Post edited 5:17 pm – December 3, 2011 by Jongware
Hi Cindy!
Well not that I know of but it's easy enough. Uh, for me it is, anyway.
//DESCRIPTION:Expand US State Abbreviations
if (app.version < '6')
doReplace();
else
app.doScript(doReplace, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Expand State Abbreviations");
We show exactly "How to download a script someone wrote out in a forum post" in video #016, ("Running a Script") in our short-and-sweet InDesignSecrets videocasts on Lynda.com!
Post edited 9:12 am – December 27, 2011 by FrederickYocum Post edited 12:40 pm – December 27, 2011 by FrederickYocum
@Jongware
Nice little script which I used on a set of business card templates that needed to go from full state names to abbreviations. I ran into an edge case however. Washington D.C. How to tell the difference?
Since the script uses grep it might be possible to do a look ahead to check for the letters D.C. or District of Columbia, I don’t know if this can be accomplished using scripting. It might be possible to do a look ahead for the postal/zip code, in fact, this would be generally useful because using postal abbrevations are usually only relevant for the state name when it is in an address block. I simply did a normal find and replace and corrected the Washingtons by hand. In any case using the script was still much quicker than 52 find and replaces.
Frederick, that's a cool reversal of the original script!
You are correct, GREP can distinguish both Washingtons using a look ahead. Change the Find entry in the abbreviations array from
[ "Washington", "WA" ]
to
[ "Washington(?! D\.C\.)", "WA" ]
and the problem ought to be solved — you don't have to change anything else in the script. For your other suggestion,
It might be possible to do a look ahead for the postal/zip code, in fact, this would be generally useful because using postal abbrevations are usually only relevant for the state name when it is in an address block.
I need to see some examples of what your USPS codes look like. I don't see many of those over here in Holland