How to remove directories by identifying with its file name(i.e rev.config)?
I wrote the following code to copy the files from one directory to another diorectory.Now i like to remove the some directories in the destination folder wherever the file(rev.config) includes.the folder which includes rev.config those folders should be removed using perl?Help me fix it
use File::Copy qw( copy);
use File::Find::Rule qw( );
use File::Path qw( make_path );
my $input_dir = '/home/rpiasa/DMS_DEMO/project_space';
my $output_dir = '/home/rpiasa/output/project_space';
my %created;
for my $in (
File::Find::Rule
->file()
->name(qr/^[^.].*\.config$/)
->in($input_dir)
) {
my $match_file = substr($in, length($input_dir) + 1);
my ($match_dir) = $match_file =~ m{^(.*)/} ? $1 : '.';
#print $match_dir,"\n";
my $out_dir = $output_dir . '/' . $match_dir;
my $out = $output_dir . '/' . $match_file;
make_path($out_dir) if !$created{$out_dir}++;
copy($in, $out);
}
• 876 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Hello finddata15!
We believe that this post does not fit the main topic of this site.
This is not a question about bioinformatics, but about programming. You may find answers on Stack Overflow.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
I disagree with it because code i wrote for bio informatics project.Am using perl .In bio informatics perl is used.Then why shouldnt try it here.
Because this same code is not doing anything specific to bioinformatics, it's just plain programming.