#! /usr/bin/perl
#
# move files into subdirectories based on 4 character prefix

$count = 0;
opendir(DIR, ".");	# open the current working directory
while ($file = readdir(DIR) ) {
	next unless -f $file;		# ignore anything that isn't a file
	next unless $file =~ /^(....)/;	# get first 4 chars
	$prefix = $1;
	next if $prefix =~ /\./;	# don't allow dot
	next unless -d $prefix;		# 
	print "  moving $file to $prefix\n";
	system("mv $file $prefix/$file");
	$count++;
}
closedir(DIR);
print "Attempted to move $count file(s)\n";

