in reply to Directory or file not found while using copy
Here's some fuel for thought:
#!/usr/bin/perl -w use strict; use File::Copy; do_copy("path/to/dir","path/to/dest"); exit(0); sub do_copy { my ($src_path,$dest_path)=@_; opendir(DIR,$src_path) or die "$src_path: $!"; while(my $entry=readdir(DIR)){ next if $entry eq '..'; next if $entry eq '.'; my $sfqp = $src_path . "/" . $entry; my $dfqp = $dest_path . "/" . $entry; if ( -d $sfqp ) { mkdir $dfq,0755; # Change to your mask do_copy($sfqp,$dfqp); # Recursion } elsif ( -f $sfqp ) { copy $sfqp,$dfqp or die $! } } }
Now, if you just want to move files ending in ".cmd" you'd add a line just before the copy call something like:
so it will ignore all but what you want.next unless $entry =~ m@\.cmd$@;
|
|---|