#!/usr/bin/perl
#
# @(#)deepen 1.2 91/11/25
#
#  Copyright (c) Steve Kinzler - October 1991.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged.
#
#  No responsibility is taken for any errors on inaccuracies inherent
#  either to the comments or the code of this program, but if reported
#  to me, then an attempt will be made to fix them.

# deepen - convert faces database directory structure
#   Converts the current directory from host.dom.ain/user format to
#   ain/dom/host/user format.
# Steve Kinzler, kinzler@cs.indiana.edu, October 1991

foreach (`ls`) {
	chop;
	next if /^\./;
	if (-d && $_ eq 'misc.' ) {
		system("mv misc. MISC");
	} elsif (-d && $_ eq 'etc.') {
		system("mv etc. etc");
	} elsif (-l) {
		warn "$0: symlink $_ may be invalid now";
	} elsif (-d) {
		$list{join('.', reverse(split(/\.+/)))} = $_;
	}
}

foreach $aindom (sort keys %list) {
	@dirs = split(/\.+/, $aindom);
	next unless $#dirs;
	$tail = pop @dirs;
	$dir  = join('/', @dirs);
	system("mkdir -p $dir; mv $list{$aindom} $dir/$tail");
}
