Bash Scripts

This page contains several little bash scripts I've written and found useful. I include them here in the hope that others will also find them useful, but more because I hope they will inspire new Linux users to go beyond the desktop and discover the power of the command line, of scripting languages, and the like.

cdr_copycd

This little script simply copies a CD to CDR. It's a nice example of how something you could do with a graphical program, like xcdroast or k3b can be done more easily from the command line, with a little bit of scripting.

Run cdrdao -h for usage info.

pdf2djvu

A lot of journals now have old and new papers online, but they are almost always PDFs with just a single page per visual sheet. That's fine when reading articles online, but it's a pain when you want to print them. I'd much prefer a copy that is like what I'd get from a photocopier: Two journal pages per sheet of paper. It saves paper, for one thing, and is easier to read.

This script solves that problem, and others. Handed a PDF (or a set of single pages), it converts it into the djvu format, optionally creating double pages. The script has a lot of options that allow one to manipulate the pages along the way, and it is capable of using a configuration file that contains commonly used settings. For example, some PDFs have very large margins and, as a result, the printed pages come out with type that is too small. The solution is to crop the page images, and pdf2djvu will do that.

Run pdf2djvu -h for usage info. You'll need ImageMagick and either the xpdf or netpbm utilities to use the script. As well, of course, as djvulibre.

scan2djvu

This is a script I wrote to scan papers to put online for my classes. It uses an automatic document feeder to scan a set of pages, which it then assembles into a djvu. There are options that allow pages to be rotated, etc, and there is a general option that allows one to use the full power of ImageMagick's convert utility to do whatever one wants to the pages. Speaking of which, you will need ImageMagick to use this script, as well as djvulibre. But these are available for pretty much every Linux distribution and for OSX, as well. You will also need the next two utilities, which scan2djvu calls.

Run scan2djvu -h for usage info.

scanpages

This is a simple script to scan a bunch of pages from the ADF in a format suitable for conversion to djvu. It uses the scanimages utility from SANE.

Run scanpages -h for usage information.

tiff2djvu

This script takes a set of bitonal page images, either as tiffs (preferably), pbms, or pnms, and assembles them into a djvu file. It is capable of rotating the pages and a few other things. It's mostly intended for use with scan2djvu, but it can be used on its own, if (say) you need to make some manual changes to the pages after you scan them.

Run tiff2djvu -h for usage information.