#!/usr/bin/perl

# A simple script to move the Aitoff images in the current directory
# into a set of directories one for each day.

opendir(CDIR, '.') || die "Failed to open dir\n$!\n";

@list = readdir(CDIR);

closedir(CDIR);

foreach (@list) {
    if (/s_([12][0-9]{3})_([0-9]{3})_.+\.fit/) {
	-d "$1_$2" || mkdir("$1_$2");
	rename($_, "$1_$2/$_") || warn "Failed to move $_:\n$!\n";
    }
}
