by xilduq » Fri Jul 21, 2006 3:44 pm
First, make a backup using tar or whatever.
Since you're using linux, you should have Perl available. Below is a shell command which will:
1.) find all plain files, with the extension .html or .htm, in and below the directory /home/siteroot
2.) escape any non-letter characters, such as spaces, in the pathname,
3.) filter out those files which do not contain 'href',
4.) do an in-place, one-liner, Perl search-and-replace on <a href... tags and <link ...href... tags, but, only turning to lowercase that which lies between the href=(with optional quote) and the first occurence of either '>' or '?' or another quote
Note: a backup file, with the extension .bak, is created for each file
find /home/siteroot -type f \( -name '*.html' -o -name '*.htm' \) | perl -lne "print quotemeta" | xargs grep -li href | xargs perl -i'.bak' -pe 's/(<(?:a|link)(?:(?!href).)+href\s*=\s*[\x27"]?)([^>?\x27"]+)/$1\L$2/igs'
<eom>