#! /usr/bin/perl -l use strict; use warnings; use File::Find; use File::Basename; @ARGV = grep { -d or !warn "`$_': not a directory!\n" } @ARGV; die "Usage: $0 []\n" if @ARGV < 2; my $target=shift; find { no_chdir => 1, wanted => sub { return unless /\.output$/; my $dest="$target/" . basename $_; rename $_, $dest or warn "Can't move `$_' to `$dest': $!\n" and return; print "`$_' => `$dest'\n"; } }, @ARGV; __END__