<div><br></div>> if (( -f $file) && ( $file =~ /\.(inp|pd2)$/ ))<br><br>without much formal requirement definition, try to start with this<div><br> if (( -f $file) && ( $file =~ /^\w+-\w+\.(inp|pd2)$/ ))</div>
<div><div class="gmail_quote"><br></div><div class="gmail_quote">On Tue, Oct 23, 2012 at 10:57 AM, Chris Jones <span dir="ltr"><<a href="mailto:cj@enersave.ca" target="_blank">cj@enersave.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thank you so much for all your help!<br>
I must make a donation to something in compensation for making my work life more productive!<br>
<br>
I have a bunch of files to delete in sub-directories.<br>
<br>
I only want to keep files with the following pattern:<br>
SomeFIle-Name.inp<br>
SomeFIle-Name.pd2<br>
<br>
Any other files should be deleted. Unfortunately my simple search did not separate files such as:<br>
SomeFIle-Name.r2.inp<br>
SomeFIle-Name.r2.pd2<br>
SimFile-Name.r2 - Baseline Design.inp<br>
<br>
#!/usr/local/bin/perl<br>
use strict;<br>
use File::Find;<br>
<br>
$\="\n";<br>
$,="\n";<br>
<br>
my $start=("./");<br>
<br>
finddepth (\&wanted, $start);<br>
sub wanted {<br>
my $file = $_;<br>
#mod, eux, cfg test for each one<br>
if (( -f $file) && ( $file =~ /\.(inp|pd2)$/ ))<br>
{<br>
print "File $file, keep\n";<br>
}<br>
else<br>
{<br>
print "File $file, delete\n";<br>
}<br>
}<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
>><br>
Christopher Jones, P.Eng.<br>
Suite 1801, 1 Yonge Street<br>
Toronto, ON M5E1W7<br>
Tel. <a href="tel:416-203-7465" value="+14162037465" target="_blank">416-203-7465</a><br>
Fax. <a href="tel:416-946-1005" value="+14169461005" target="_blank">416-946-1005</a><br>
email <a href="mailto:cj@enersave.ca" target="_blank">cj@enersave.ca</a><br>
<br>
______________________________<u></u>_________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/toronto-pm</a><br>
</blockquote></div><br></div>