Thursday, September 13, 2012

bulk rename of file extensions

When the software that drives my scanner on my mac saves PDF files it uses the extension ".PDF".  I would like to have the extension ".pdf" on the files.

I accomplished this by renaming the files using this shell snippet:

for x in *.PDF; do
  y="`echo "$x" | sed -e s/\.PDF$/.pdf/g`"
  mv -i "$x" "$y-"
  mv -i "$y-" "$y"

There are two moves because the file system acts case insensitive and recognizes the initial and final file name as the same. Also the file name variables are quoted because of spaces in the file names.

Friday, September 7, 2012

JPEG scans to PDF

Long ago I would scan pages of paper to JPEG images at 150dpi, more recently I have been scanning to PDF, and today I finally got around to converting all the old scans into the new format.  This presented a challenge because not all of the scan files are the same dimensions.

My first challenge was figuring out what the dimensions of each JPEG file were, which was not so hard once I realized that I was using Portable Any Map intermediates between the JPEG file and the Postscript version that gets turned into a PDF file, the intermediate format has the dimensions of the image in plain text in a header which I could just read.

The rest of the challenges were minor in comparison, either because I solved them in the past, or were solved by a quick search online.

This first script converts an incoming Portable Any Map to a properly sized postscript file with a 150dpi version of the image as the entire page: pnmtops-150dpi-filter
#!/usr/bin/perl -w
use strict;
my $ver = <STDIN>;
my $size = <STDIN>;

my ($width, $height) = ($size =~ m{^(\d+) (\d+)$});

$width = $width / 150.0 + 1.0 / 72.0;
$height = $height / 150.0 + 1.0 / 72.0;

local *OUT;
open(OUT, "|-", "pnmtops", "-dpi", "150", "-equalpixels", "-nocenter",
        "-width", $width, "-height", $height, "-setpage");

my $buff;

print OUT $ver;
print OUT $size;
while(read(STDIN, $buff, 8192)) {
    print OUT $buff;


The above script gets used by the script that I use to do the conversion of directories to pdf files: scan2pdf
if [ "$2" == "" ]; then
  echo "converts a directory of 150dpi scan images to a properly fit pdf"
  echo use: input-directory output-file

for x in "$1"/*.jpg; do
  djpeg "$x" | pnmtops-150dpi-filter
done |
ps2pdf14 - "$2"

This seems to be working well for me, it even produces PDF files with varying page sizes.

warm rainbow jacket

One day about two years ago I was at the fabric store and one of the staff knew that I liked wearing very colorful things, so they showed me a bolt of rainbow printed fleece.  At that point I got enough for two fairly small ponchos and added them to the mix of fleece I was wearing through the winter.  The following winter I saw the fleece at the store again and got more with the intention of making a jacket type thing, and made three parts that I could wear mixed with other things.  Recently I decided to take the parts and make them into a single jacket.

I also updated the waterproofing coating on the jacket, so it is mostly waterproof in the rain and snow.  The fleece was very warm before I made it into a jacket, now it feels even warmer.

I am considering making the jacket a little longer, about trenchcoat length.

I also made the leg warmers from the same rainbow print fleece.

Monday, September 3, 2012

Pill case cover

Last year I started taking some daily pills, and got myself a weekly pill box to remind me if I have taken them yet on a particular day.  One time last summer I went on a trip and found that the box would not keep itself closed in my backpack, so it spilled which was annoying.  In response I came up with a very easy solution, make a box that was just big enough to slide the pill box into.

It works extremely well.  Now I do not need to worry at all about where I pack it for overnight stays, multi-week trips, or even camping. It will no longer be opening and spilling in my bag.

The case itself is made of plastic canvas and sewn with strips of used shopping bags.

positive clothespins

One of my friends was making clothespins with cute words on them to give out for christmas last year, and I extended the idea to something to share and gift to people at parties and festivals.

I have heard people wondering where they come from many times, after seeing them clipped on people all over the place at a party.  Also many people seem to love these.

Not only can they be shared and clipped on people, they can also hold clothes onto lines, and anything else one might use a clothespin for.

Transparent wallet

In university I had a meal plan, and the holder it was in was transparent on the inside and would hold both the meal plan slip and my student id card.  I liked the convenience of being able to see what was in it like that.  Later I made myself a wallet out of a milk bag.

It is all transparent and sewn together.

The previous one lasted about two years, and this one was made a few days ago.

Other previous attempts were walets made from overhead sheets and packing tape; just packing tape; sandwich bags and tape; and tape with cardboard. None of those lasted nearly as long as a milk bag with thread.

When I had a bus pass I could just put it on one of the outside surfaces and not even open my wallet to show it.

I like it.

Sunday, September 2, 2012

My toothbrush holder

I keep my toothbrush in one of those plastic toothbrush tubes, since it is traveling with me all over the place.  I found the tube to be boring, so I tried painting right on the plastic, and later using sharpies on the plastic, but both rubbed fairly quickly.  Eventually I just wrapped it in hockey tape and painted that.

I also glossed it when it was done.  The split where the toothbrush tube opens is part way into the yellow stripe.

I expect the tube will actually last longer because of the reenforcement on the surface.