BEGIN { use strict; use File::Next; use File::Util; use File::Copy; } my ($file_util) = File::Util->new(); move_files() sub move_files { open (FILE, ") { next if ($_ !~ /\w/); my ($full_path) = ($_ =~ /\d*\s(.*)/); my ($par_dir, $file_name) = ($full_path =~ /.*\\(.*)\\(.*)/); my ($file_no_ext) = ($file_name =~ /(.*)\.pdf/); my ($first_five) = ($file_no_ext =~ /(\d{5}).*/); $first_five .= 'xxx'; if ($par_dir =~ $file_no_ext) { my $directory = "\\\\filervoca\\e\$\$\\activeads\\adwatchfolders\\$first_five\\$file_no_ext"; #print "path: $full_path\npar_dir: $par_dir\nfile_name: $file_name\nfirst_five: $first_five\ndirectory: $directory\n"; #print "dir doesn't exist, need to make it\n"; $file_util->make_dir($directory, '--if-not-exists') or die "$!"; copy($full_path, "$directory\\$file_no_ext"."00.pdf") or die (print "$!"); } sleep 10; } close FILE; }