$bak = ".bak"; # backup extension $target = "*.htm"; # target files to process $from = "\/mhs\/psychotherapy\/"; # string to change $to = "file:\/\/\/c|\/mhs\/psychoth\/"; # what to change it to # now run through all subdirectories looking for files open(FIND, "find . -name \"$target\" -print |") || die "Couldn't run find: $!\n"; while ($filename = ) { chop($filename); if (($filename =~ /\/psychoth\//) || ($filename =~/\/file\//)) { next; } print "\nProcessing file: $filename...\n"; $newname = $filename; $newname =~ s/./.\/file/; open (OLD,$filename) || die "Couldn't open old file $filename\n"; open (NEW, ">$newname") || die "Couldn't open new file as $newname\n"; while () { s/$from/$to/g; print NEW; } close NEW; }