*\PL\* *\pl-*.fbrb *_pl-*.fbrb *\*_pl-00.fbrb *\pl-00.fbrb *\polish\* *\psarc\polish*.psarc *_POL.* *_POLISH.SUB *_POL_* *_po.xvag *_polish.* *.pl.* *_pl.psarc *_pl2.psarc *_pol.* *_por.* #### use File::Slurp; use File::Copy::Recursive qw(rmove); use File::Basename; my @patterns; my @dirs; my $searchDIR = $ARGV[0]; search_dirs($searchDIR); get_patterns(); move_files(); sub search_dirs{ my ($dir) = @_; my ($dh); if ( !opendir( $dh, $dir ) ) { return; } while ( my $file = readdir($dh) ) { next if ( -d $file ); my $path = "$dir/$file"; if ( -d $path ) { search_dirs("$path"); } else { push( @dirs, "$dir/$file" ); } } } sub get_patterns{ my @files = read_dir('patterns'); foreach my $element(@files){ open my $file, '<', "patterns/$element"; while(<$file>){ chomp $_; push @patterns, $_; } close($file); } } sub move_files{ for my $element(@dirs){ my($filename, $path, $ext) = fileparse($element, qr/\.[^.]*/); if ( $filename =~ $patterns ) { print "Found $element\n"; #rmove($element, "non-english/$path$filename$ext"); } if ( $path =~ $patterns ) { print "Found $path\n"; #rmove($path, "non-english/$path); } } }