: # creates Avery 5266 labels - for file folders # bourne, korn or bash script # requires groff typesetting command # allows direct access to labels by allowing user to type in a label # number, and it remembers where the last number was. # Need a different label? Please mail me. davidbu"at"www.los-gatos.ca.us # fiddle with these until everything looks OK # "i" means "inches", so .5i is half an inch, for example POINT_SIZE="12" VERTICAL_SPACING="14" TOP_MARGIN=".sp 0" LEFT_MARGIN=".po .75i" RIGHT_COLUMN=".po 4.75i" INTER_LABEL_PAD=".sp .28i" # dont fiddle with anything else except the last line of the script. LABELS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" EXTENDED_INSTRUCTIONS="Labels are numbered vertically, 1-15 in column 1 and 16-30 in column 2. When prompted to enter label text, enter the text for the label or: type a different number to print a different label, the letter \"d\" for \"done\" (prints all labels), or \"q\" to quit without printing any labels. " if [ -s "$HOME/.file_labels" ] then read CURRENT_NUMBER < "$HOME/.file_labels" fi # begin program loop while : do case "$CURRENT_NUMBER" in "")CURRENT_NUMBER="1" ;; 31)CURRENT_NUMBER="1" EXTENDED_INSTRUCTIONS="Warning! That was the last label on the page.... Better say \"done\" now! " ;; esac # begin loop echo "${EXTENDED_INSTRUCTIONS}This label will be label number $CURRENT_NUMBER Enter the text for this label: " unset EXTENDED_INSTRUCTIONS echo -n "Line 1: " read TEXT_OR_NUMBER_LINE_1 case "$TEXT_OR_NUMBER_LINE_1" in [0-9]|[0-3][0-9])CURRENT_NUMBER="$TEXT_OR_NUMBER_LINE_1" continue ;; [Qq]|[Qq][Uu][Ii][Tt])exit ;; [Dd]|[Dd][Oo][Nn][Ee])break ;; *)eval LABEL_TEXT_LINE_1_$CURRENT_NUMBER=\"$TEXT_OR_NUMBER_LINE_1\" # echo "LABEL_TEXT_$CURRENT_NUMBER will be: $TEXT_OR_NUMBER" ;; esac # we only get here if we are not done and did not quit echo -n "Line 2: " read TEXT_OR_NUMBER_LINE_2 eval LABEL_TEXT_LINE_2_$CURRENT_NUMBER=\"$TEXT_OR_NUMBER_LINE_2\" echo "" # we only increment if we have really done a label. # fast, portable, inelegant case "$CURRENT_NUMBER" in 1)CURRENT_NUMBER="2";; 2)CURRENT_NUMBER="3";; 3)CURRENT_NUMBER="4";; 4)CURRENT_NUMBER="5";; 5)CURRENT_NUMBER="6";; 6)CURRENT_NUMBER="7";; 7)CURRENT_NUMBER="8";; 8)CURRENT_NUMBER="9";; 9)CURRENT_NUMBER="10";; 10)CURRENT_NUMBER="11";; 11)CURRENT_NUMBER="12";; 12)CURRENT_NUMBER="13";; 13)CURRENT_NUMBER="14";; 14)CURRENT_NUMBER="15";; 15)CURRENT_NUMBER="16";; 16)CURRENT_NUMBER="17";; 17)CURRENT_NUMBER="18";; 18)CURRENT_NUMBER="19";; 19)CURRENT_NUMBER="20";; 20)CURRENT_NUMBER="21";; 21)CURRENT_NUMBER="22";; 22)CURRENT_NUMBER="23";; 23)CURRENT_NUMBER="24";; 24)CURRENT_NUMBER="25";; 25)CURRENT_NUMBER="26";; 26)CURRENT_NUMBER="27";; 27)CURRENT_NUMBER="28";; 28)CURRENT_NUMBER="29";; 29)CURRENT_NUMBER="30";; 30)CURRENT_NUMBER="31";; esac echo "$CURRENT_NUMBER" > "$HOME/.file_labels" done # ok, print it! # this creates troff output { echo ".ps $POINT_SIZE .vs $VERTICAL_SPACING $TOP_MARGIN $LEFT_MARGIN .mk aa" for LABEL in $LABELS do case "$LABEL" in 16)echo ".rt \\n(aau $RIGHT_COLUMN" ;; esac eval THIS_LABEL_LINE_1=\"\$LABEL_TEXT_LINE_1_$LABEL\" eval THIS_LABEL_LINE_2=\"\$LABEL_TEXT_LINE_2_$LABEL\" case "$THIS_LABEL_LINE_1$THIS_LABEL_LINE_2" in # anything? ?*)echo "$THIS_LABEL_LINE_1 .br $THIS_LABEL_LINE_2" ;; # nothing # blank - two lines *)echo ".sp .sp" ;; esac echo "$INTER_LABEL_PAD" done } | groff > /tmp/file_labels # let groff finish sleep 1 # edit the last line of the script to match your printer, if your printer # is not the default # re-type the next line on the command line to re-print the most recent labels lpr /tmp/file_labels