Roland's scripts page |
|
This page contains a number of scripts that I have written over the years. I’ve put them here because others might find them useful as well.
Most of these scripts try to only use features and commands that are usually available on UNIX-like operating systems. If a script is specific to a certain OS, it will be noted in the remarks.
The listed requirements do not include those utilities and shells that are
customarily available on UNIX-like operating systems. Those include sh,
sed, awk, grep, du, df, rm, cat and echo among others. The
scripts usually include tests to see if the non-standard programs they need
are available.
All these scripts are now in the public domain. Note that some of these scripts will need changes before they will work properly on your system!
This script syncronizes the partitions on my primary disk to a secondary disk that is partitioned exactly the same. By running this script every night from cron, I get a fresh backup every night, and during the day I can still use the previous backup to restore accidentally deleted files.
| Script: | backup-local |
| SHA1 checksum: | 11fea0423e2cf9a0c5d829c856d9198fc3722516 |
| Requires: | rsync |
This script cleans the current directory. As distributed it removes LaTeX
auxiliary files like .dvi, .aux, .log etc, object files and libraries
(.o, .a, .so) and editor backup files (*~). But it is easily augmented
to remove other files as well.
| Script: | clean |
| SHA1 checksum: | 9de96bfe657bd671d7fcd06057a484956ae7e0dd |

This script asks for address data, and then produces a postscript file suitable for printing on an 110×220 mm envelope by any printer that prints envelopes from the middle of the feeder.
The resulting file (A4-size) looks like the picture on the right, which is turned 90° anti-clockwise, so that the top of the page is on the left.
Beware that you should edit this script before using it! The variables
MYNAME, MYADRES and MYTOWN need to be changed to your address, which
will be printed on the top-left side of the envelope.
| Script: | envelope |
| SHA1 checksum: | 601c6fb2ff432f189f16dd2f7cd2ec5c1e68d5d8 |
This script dumps UFS filesystems, and writes them to files in the specified
directory after compressing them with xz.
directory.
This script is FreeBSD specific! It can possibly be used on OpenBSD and NetBSD, but I haven’t tested it. Linux doesn’t use the UFS filesystem.
| Script: | dodumps |
| SHA1 checksum: | cce9e75cb88f997ff59a9a480eef541431ad4996 |
This script takes as its single argument the name of a PostScript file. It calculates the so-called BoundingBox for the actual drawn contents of the file, and replaces the existing one with this newly calculated one.
| Script: | fixbb |
| SHA1 checksum: | 351d28e21b923d080be5493f8e36f64e22d967d9 |
| Requires: | gs, configured with the bbox device. |
This script converts all sound files in flac format in the current directory to ogg vorbis format.
| Script: | flac2ogg |
| SHA1 checksum: | 78a10593702ed9072a8dfb4db6e2fd86e72207cf |
| Requires: | oggenc compiled with flac support. |
If this script is supplied with an image file name, it prints out a
well-formatted <img> tag. Feeding this script a file in a format that
[identify][] doesn’t understand will produce odd results.
| Script: | imgsize |
| SHA1 checksum: | ed79066664e037f4be3a620bc3a67d1d91d158eb |
| Requires: | [identify][] |
The make-flac script takes as input a number of wav files and a file
containing the song data, and converts them to flac format.
Since the flac format is lossless, this is IMHO the best way to backup CD’s. A
flac file takes about half the space of an equivalent wav file. That is a
better compression than can be achieved on wav files using compression tools
like gzip, bzip2 or zip. A lot of open-source software players end even
some hardware players (like the iAUDIO M5 and other Cowon models) can play
flac files.
The wav files should be named trackNN.cdda.wav where NN is a number, as
produced by cdparanoia. The format of the titles
file is described inside the script.
| Script: | make-flac |
| SHA1 checksum: | 779d830e5dcdf386c1c5a0e9c45b3db5c57ad316 |
| Requires: | perl, flac |
The make-mp3 scripts takes as input a number of WAV files, and a file containing the song data, and converts them to variable bit rate MP3 format.
Note that the MP3 format is encumbered by patents, and that ogg vorbis usually produces smaller files with better quality. But MP3 is supported by many more devices.
The same restriction to the input files names as used by make-flac applies.
| Script: | make-mp3 |
| SHA1 checksum: | 9d70247a3746c75a50e8e3206fc53a75664c8c99 |
| Requires: | perl, lame, id3ed |
This script converts a number of wav files, and a file containing the song data, to ogg vorbis files.
| Script: | make-ogg |
| SHA1 checksum: | e06db8640415965a2380b1b3080a19e8f91f8575 |
| Requires: | perl, oggenc, normalize |
Adds a copyright notice to jpg pictures. I use it to mark the photos I take
and put online. You need to replace my copyright notice with yours before
using this script!
This script has been re-written in Python and now uses multiple cores on machines that have them.
| Script: | markphotos |
| SHA1 checksum: | 1adce8dcf1d925d96bdef47a9d45e9eefdb1e062 |
| Requires: | exiftool |
When given a number of picture file names, this script generates an
index.jpg picture containing thumbnails of all the pictures.
| Script: | mkindexpic |
| SHA1 checksum: | b0b5bd3fd349801ce110eb60ebb70b299ac8bccf |
| Requires: | montage |
Creates a web page index.html in a directory of jpg files. The webpage
references all the jpg files in the current directory.
| Script: | mkphotopage |
| SHA1 checksum: | 15a2fd48100cd34682748dd397a595476c0dde39 |
| Requires: | python 2.7 |
When this script is executed in a directory containing jpg files, it
creates a subdirectory named sm where smaller copies of the jpg files are
stored. The default size is 15% of the original, but that can be changed
on the command line.
| Script: | mksmall |
| SHA1 checksum: | a8cee98886ae3d4cab75abecb6a965aad2f442f8 |
| Requires: | [convert][] |
Renames files with spaces in their filename by replacing those with underscores.
| Script: | nospaces |
| SHA1 checksum: | 08bc82cbef9cae6b803dc670ee6bae8912fdecf6 |
This script thee arguments. First the number of a start page (N), second the
number of a start page (M) and third the name of a file. The numbered pages are
then extracted and written as pageN-M.pdf or pageN.pdf if M equals N.
| Script: | pdfselect |
| SHA1 checksum: | 6674b29657d9e6d84a92883fcde864264b25e763 |
| Requires: | gs, configured with the pdfwrite device. |
This script is a shortcut to render povray scenes at different resolutions and quality levels. I’ve used it for both doing quick checks on scenes that I’m working on and the final renderings.
Available resolutions range from a ‘small’ 320×200 to a ‘huge’ 1280×1024. Quality options range from ‘+Q3’ to ‘+Q11’, with appropriate extra options for every quality setting.
| Script: | povmake |
| SHA1 checksum: | 1b654a0174f2180ddfe5dc6e9cc3c61a001a1b01 |
| Requires: | povray |
Converts uncompressed DICOM format files to JPEG format, via PGM.
| Script: | raw2pgm |
| SHA1 checksum: | 1a70154fab1997f3addc2b82e5afa40fb5fb849d |
| Requires: | [convert][] |
Renames files converting uppercase characters to lower case.
| Script: | tolower |
| SHA1 checksum: | 8c22f85a1b19d70fea80ec6f289c2010fade067f |