The macro at Abbreviations: States, Months Macro requires you to select the state names, one-at-a-time, and run the macro. Is there a way to have a script change all state names in one series of find/replace steps, if you have a long list of addresses?
I guess I could build a macro with 50 find/replace actions, one for each state, but I'm hoping there's an easier way.
I'm the culprit behind that macro. Yes, it was designed to convert a single selection. I'm not adverse to providing a batched version but first I'd like a peek at the data you would like to feed it. It doesn't have to be the actual data, just resemble the actual data.
My first thought is the new macro would prompt you for a file to convert state names (as well as the format to convert to). And after conversion write a new file with the edited names.
...with instructions on running it from the Terminal. It did great, so I have something that works for future needs. But it would be so much nicer to just do it from the Finder with Keyboard Maestro.
He's not very familiar with Keyboard Maestro, but thought I might have AppleScript call the script. However, looking at the the "Execute a Shell Script" action, perhaps KM can run it directly. As you said, it would probably have to work on a closed file (selected file in the Finder).
Yes, Keyboard Maestro can run that directly with the Execute a Shell Script action but I believe you'll have to use a variable name for the file where $1 appears after picking a file.
The only caveat with the script is you might want to anchor the search to the end of the line to only affect that occurence. Arizona$ for example.
on your original sample data in an open file. No need to select a file. The macro selects all the text, copies it to the Clipboard, passes that as a variable to the Perl code, which steps through each line making the substitution.
It could be optimized but it seemed pretty quick banging out one line at a time.
Thanks, but when I run this on a BBEdit file, the state names don't change, but the number "12" is appended to each line. What might be the cause of that?
I see a set of date changes at the end of the states, and the last one ends with "12." Could that be involved?
Yes, I didn't realize the state name had to be at the end of each line. I thought it might find them anywhere. Now that I know, I can make good use if it. Thanks!