da: (bit)
[personal profile] da
I will freely admit this post will be of limited interest, but I'm quite happy with this result, and maybe you will be too, if you're a big 'ol label-making geek. :)

So, part of GTD is the importance of having labeled manila file-folders. I can corroborate that printed-label folders do work better than hand-printed labeled folders. Not only do they look good, there's something viscerally fun about filing something away in a new folder.

The GTD guy recommends buying an electronic label-maker. For a number of reasons (including: the clutter factor, the expensive label-tape they use, and typing on those chiclet keyboards annoys me) I've made do with printing onto a sheet of Avery 3x10 labels in OpenOffice. While this solves those problems, this still felt like "making do" because it takes OpenOffice a full minute to open, the template is a little mis-aligned, yadda yadda.


My goal: a command-line tool to print labels in the proper format.

brian d foy wrote about perl and Avery labels some time ago, so I installed PostScript::MailLabels and gave it a whirl last night.

Wow that was easy.

Now I type into the shell:

~$ ~/bin/labeler
Project 1
Project 2
Project 3
^D


and Preview opens a .pdf with my three labels across the page. Running labeler 4x2 offsets to start at the 4th row and 2nd column (since I usually have incomplete sheets of labels to use up).

labeler full takes one label and makes a full sheet out of it.

Here's my code, based heavily on brian's:


#!/usr/bin/perl
# labeler.pl -- output postscript version of label text
# labeler.pl <position>
# labeler.pl <row>x<column>

# mostly stolen from brian d foy: 
# http://www.perlmonks.org/?node_id=413783

use strict;
use warnings;
use PostScript::MailLabels;

my $labels = PostScript::MailLabels->new;

my $position = shift || 1;
my $batch = 0;

if ($position =~ /(\d+)x(\d)/) {
    $position = (($1-1)*3 + ($2));
}

if ($position =~ /all/) {
    $position = $batch = 1;
}

die "Position must be a number or row and column (ex: 3x4)" unless 
    ($position =~/^\d+$/);
die "Position $position is greater than 30" unless ($position <= 30);

$labels -> labelsetup(
            Avery       => $labels->averycode(8160),
            PaperSize   => 'letter',
            Font        => 'Times-Roman',
	    FirstLabel  => $position,
            Y_Adjust    => 1 / 16,
            X_Adjust    => 1 / 16,
            );

$labels->editcomponent('first', 'name', 'no', 0 );
$labels->editcomponent('second', 'name', 'no', 1 );
$labels->editcomponent('third', 'name', 'no', 2 );
$labels->editcomponent('fourth', 'name', 'no', 3 );
$labels->editcomponent('fifth', 'name', 'no', 4 );

$labels->definelabel('clear');

$labels->definelabel(0,'first');
$labels->definelabel(1,'second');
$labels->definelabel(2,'third');
$labels->definelabel(3,'fourth');
$labels->definelabel(4,'fifth');
  
my $addresses = [ map { chomp; [ split /\\n/ ] } <> ];

if ($batch) {
    my @pattern = @$addresses;
    unshift @$addresses, @pattern foreach (1..29);
  }

print $labels->makelabels( $addresses );


This script will output warnings, and also needs the output data redirected to a file. So there's a tiny bash wrapper to do that, then open the file in Preview, which (oh by the way) auto-converts postscript to .pdf (which is a neat trick I didn't know before reading brian's post):


#!/bin/bash
/Users/daniel/work/labeler/labeler.pl $1 > /tmp/label.ps 2>/dev/null; open /tmp/label.ps




And that's my labeler, which I figure is at least 5 times cheaper than the tape-label machines, going by the price of the refills.

Data can come from a unix pipe or from standard input. Turning a manual task into a unix pipe command is about as good as it gets, productivity-improvement-wise. (assuming it's not a stupid task in the first place).

Oh and also, if we decide to do them this year, I think it will work wonderfully on holiday address labels, even straight from an emacs buffer of addresses, because you pipe data to it.

Date: Saturday, 22 November 2008 02:06 pm (UTC)
From: [identity profile] sulle-stelle.livejournal.com
LOVE it!

You are just the coolest!!!

December 2024

S M T W T F S
12 34567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Wednesday, 24 December 2025 03:27 pm
Powered by Dreamwidth Studios