Script for removing extra dirs in faces databases

Steve Kinzler (kinzler@iuvax.cs.indiana.edu)
Mon, 14 Oct 91 17:03:36 -0500

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: popfile
# Wrapped by kinzler@iuvax on Mon Oct 14 17:01:21 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'popfile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'popfile'\"
else
echo shar: Extracting \"'popfile'\" \(967 characters\)
sed "s/^X//" >'popfile' <<'END_OF_FILE'
X#!/usr/bin/perl
X
X# popfile - eliminate directories containing only one file
X#
X# For all subdirectories at any point beneath the current directory that
X# contain only one file, the subdirectory is removed and the file it
X# contained is move to a file with the same name as the subdirectory,
X# its former parent directory.
X#
X# The primary purpose of this script is to convert faces database
X# directories from the host.dom.ain/user/face.xbm format to the
X# host.dom.ain/user format (where "user" is the former "face.xbm" file).
X#
X# Steve Kinzler, kinzler@cs.indiana.edu, October 1991
X
Xopen(FIND, 'find . -type f -print |') || die "Can't run find ($!)";
X
Xwhile (<FIND>) {
X /^(.*)\/+(.*)/;
X $count{$1}++;
X $file{$1} = $2;
X}
X
Xclose(FIND);
X
Xfor $dir (keys %count) {
X next unless $count{$dir} == 1;
X next if $dir eq '.';
X
X $tmp = "$dir.POPFILE$$";
X (rename($dir, $tmp) &&
X rename("$tmp/$file{$dir}", $dir) &&
X rmdir($tmp)) || warn "Error popping $dir/$file{$dir} ($!)";
X}
END_OF_FILE
if test 967 -ne `wc -c <'popfile'`; then
echo shar: \"'popfile'\" unpacked with wrong size!
fi
chmod +x 'popfile'
# end of 'popfile'
fi
echo shar: End of shell archive.
exit 0