Bulk Snail Mail

In a fit of madness I agreed to maintain the mailing list for a local folk dance group. Unlike the previous maintainer who used DOS (later Windows) and dBASE, I'm generally doing this with flat files, awk and shell scripts. There are only a few hundred entries so anything more complicated is just overkill.

When I came time to do our first bulk mailing, I went to the US Post Office's web site to find the instructions. Most of the stuff is there if you look hard enough, but a few things (like the mappings of ZIP codes to Area Distribution Centers) are hard to find - it's like they want you to pay money for that kind of information. Eventually I found an online source for it.

So using sh, awk, and PostScript I wrote a script which takes a list of mailing list entries (one per line, of course), emits them in the proper order for bulk mailing of letters. The PostScript is used to print on 2-up or 3-up labels that you can buy from an office supply store. The script actually does two passes on the data - one to count the number of entries per group (5-digit ZIP, 3-digit ZIP, Area Distribution Center (ADC), or Misc) and another to actually emit the entries in the right order (all 5-digit groups, then 3-digit groups, then ADC groups, then the Misc group). Ain't batch processing wonderful?

This stuff is pretty rough, but it worked for us.  Feel free to use it if you find it useful. The input is produced from a program that dumps selected fields from our database (neither the database nor the program are supplied). The important thing to know is that the input fed to the emit_labels.sh script looks like:

zip$firstname lastname$addr-line-1$city, state  zip$addr-line-2
(yes, the fields are delimited by "$")  where addr-line-2 is optional and not used for most entries. So if you can get your own database to emit lines that look like the above and put them into a file, you can feed that result to this shell script and it will emit PostScript labels for you.

Preceding each group of labels there will be a label that identifies the group (for sorting purposes).

Be aware that the mappings of ZIP codes to ADCs are subject to change.  Check with your local Post Office to get the current information.

Software