#!/usr/bin/perl ########################################################################### # search & replace an entire filesystem.... with filemask ofc... ############################################################################ # Copyright 1998 by AltBlue [IRL: Marius Feraru] # # All rights reserved # # # # Distribute freely, except: # # * don't remove my name from the source or documentation # # (don't take credit for my work) # # * mark your changes # # (don't get me blamed for your possible bugs) # # * don't alter or remove this notice. # # # # May be sold if buildable source is provided to buyer. # # No warrantee of any kind, express or implied, is included with this sw. # # Use at your own risk, responsibility for damages (if any) to anyone # # resulting from the use of this software rests entirely with the user. # # # # Send bug reports, bug fixes, enhancements, requests, flames etc., and # # I'll try to keep a version up to date. # # # # I can be reached as follows: # # E-Mail: AltBlue # # Homepage: http://www.cs.tuiasi.ro/altblue/ # ############################################################################ ##### Set this muthafucka! if($ARGV[0]) { $directory = $ARGV[0]; } else { $directory = '.'; } ##### Filemask $mask=".html"; ##### What should be the strings ? %STRINGS = ( "/users/homes3/fourniga/c/X11/DOC_XCORAL/HTML/icons/","", ); ####### Let me do my bizness now &copacel($directory); sub copacel { local($dir) = shift; local($path); unless (opendir(DIR, $dir)) { warn "Can't open $dir\n"; closedir(DIR); return; } foreach (readdir(DIR)) { next if $_ eq '.' || $_ eq '..'; $path = "$dir/$_"; if (-d $path) { &copacel($path); } elsif ((-f $path) && ($path =~ /$mask$/)) { $path =~ s/^$d//; @attr=stat($path); print "$path ($attr[7])... "; open(FILE,"$path"); @fi=; close(FILE); foreach(@fi) { while (($search, $replace) = each %STRINGS) { $_ =~ s/$search/$replace/g; } } open(FILE,">$path"); print FILE @fi; close(FILE); print "OK\n"; } } closedir(DIR); }