in reply to Extracting Files from Multiple Directories
Said this, your question is slightly ambiguous. For if there are duplicate filenames you may have conflicts when trying to move them into "results". If you don't care about this a very rough primer may be along these lines:
Things you should particularly care about when refining this include:#! /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 <target> <source> [<sources>]\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__
|
|---|