#!/usr/bin/perl
# Global search and replace. Greps all files in the dir
# for a string and replaces it.
# Usage glob_rep search_string replace_string.
$search = @ARGV[0];
$replace = @ARGV[1];
@files = `grep -l $search *`;
@files = grep !/not permitted/, @files;
foreach $file (@files) {
open (FILE, $file);
@lines =
close FILE;
open (TEMP, ">temporary.file.name");
foreach $line (@lines) {
$line =~ s/$search/$replace/g ;
print TEMP $line;
}
close TEMP;
`mv -f temporary.file.name $file`;
}
10 Ağustos 2007 Cuma
Mass File Renaming Script
Subscribe to:
Kayıt Yorumları (Atom)
0 Comments:
Post a Comment