#!/usr/bin/perl $DIR1="/users/model/data/reports"; $DIR2="/users/model/data/reports/temp"; &Filter($DIR1); &Filter($DIR2); exit(0); sub Filter { local($dir) = @_; opendir(DIR,$dir); while ($file = readdir(DIR)) { next if !($file =~ /\.temp/); unlink("$file");} closedir(DIR); opendir(DIR,$dir); while ($file = readdir(DIR)) { next if !($file =~ /\.report$/ ); open (INPUT,"<$file") || die "Error Opening File. $!\n"; open (OUTPUT,">>$dir/$file.temp") || die "Error Opening File for W +rite. $!\n"; foreach $read(<INPUT>){ if ($read=~ s/'//g) { print OUTPUT "$read"; } else {print OUTPUT "$read";} } close (INPUT); close (OUTPUT); } closedir(DIR); opendir(DIR,$dir); @model_reports = readdir(DIR); closedir(DIR); for (@model_reports) { next if !($_ =~ /\.temp$/ ); $oldname = $_; $_ =~ s/.temp//; rename("$dir/$oldname","$dir/$_"); #unix } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strip Quotations from files
by FoxtrotUniform (Prior) on May 30, 2002 at 18:51 UTC | |
by grinder (Bishop) on May 31, 2002 at 21:06 UTC | |
by ngraham (Initiate) on Jun 03, 2002 at 07:08 UTC |