I am trying to match the regex of the filename and if it matches i want to move the file into another directory.But when i run the script, i get the error as "move failed: Invalid cross-device link".Please help me.The code is given below:
#!/usr/bin/perl -w use File::Copy; $InDir = $ARGV[0]; $OutDir = $ARGV[1]; if (!opendir(DIR,$InDir)) { print "Bad Dir $InDir\n"; exit 1;} while(my $Infile = readdir(DIR)) { if ($Infile =~ 'F\d{8}\.\d{4}\+\d{4}\-\d{4}\+\d{4}_.*') { move("$Infile", "$OutDir") or die "move failed: $!"; } elsif ($Infile =~ 'F\d{8}\.\d{6}\+\d{4}\-\d{6}\+\d{4}_.*' ) { <.....do something........> } }
In reply to Move a file to another directory based on regex match by DAN0207
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |