Date: Mon, 18 Jan 1999 17:57:38 -0500 (EST) From: Sam Magee <webadmin@adsight.com> To: freebsd-isp@FreeBSD.ORG Subject: Re: Need non-case sensitive fs Message-ID: <Pine.BSF.4.02A.9901181752170.21426-100000@winter.adsight.com> In-Reply-To: <36A33253.106C@echidna.com>
next in thread | previous in thread | raw e-mail | index | archive | help
I've used this script, which I hacked from a sample of something
in the Camel book to convert webs to mostly case sensitive
lower case. It seemed to catch about 99% of the problems I
had with sites coming from Macintoshes.
Put yourself in the public_html directory, create ../public_new
and run this (standard disclaimers of course about this not
being suited to any person's needs, etc):
#!/usr/bin/perl
# Converts Web site to use all lowercase links
# Changes file names and anything in HTML TAG (Some exceptions)
# Makes web copy from public_html to ../public_new/ (must exist)
@inpath = ("./",);
@outpath = ("../public_new/",);
# index into the patharrays
$curlevel = 0;
# Start at the top
&dodir('.');
sub dodir {
local($dir,$nlink) = @_;
local($dev,$ino,$mode,$subcount,@filenames);
($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
opendir(DIR,'.') || die "Can't open directory";
@filenames = readdir(DIR);
closedir(DIR);
if ($nlink == 2) { # no sub-dirs
for (@filenames) {
next if $_ eq '.';
next if $_ eq '..';
$name = $inpath[$curlevel] . $_;
$newname = $outpath[$curlevel] . $_;
print "Level=$curlevel ",$name," <--> ",$newname,"\n";
&convert($name,$newname);
}
}
else {
$subcount = $nlink - 2;
for (@filenames) {
next if $_ eq '.';
next if $_ eq '..';
$name = $inpath[$curlevel] . $_;
$newname = $outpath[$curlevel] . $_;
print "Level=$curlevel ",$name," <--> ",$newname,"\n";
&convert($name,$newname);
next if $subcount <= 0;
($dev,$ino,$mode,$nlink) = lstat($_);
next unless -d _;
chdir $_ or die "Can't cd to $name";
++$curlevel;
$outpath[$curlevel] = "../" . $outpath[$curlevel - 1] . $_ . "/";
$inpath[$curlevel] = "../" . $inpath[$curlevel - 1] . $_ . "/";
&dodir($name,$nlink);
chdir '..';
--$curlevel;
--$subcount;
}
}
}
# Called by covert($name,$newname)
sub convert {
($name,$newname) = @_;
$newname = &lcs($newname);
if (-d $name) {
system("mkdir $newname");
}
elsif (-B $name) {
system("cp $name $newname");
}
else {
open (INFILE,$name) || die "Can't open $name";
open (OUTFILE,">$newname") || die "Can't create $newname";
while (<INFILE>) {
$instr = $_;
$instr=~s/(<[^>]*)/&lcs($1)/eg;
print OUTFILE $instr;
}
close(OUTFILE);
close(INFILE);
}
}
sub lcs {
$string=@_[0];
unless (/INPUT/i || /MAP/i || /META/i) {
$string=~tr/A-Z/a-z/;
}
return($string);
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.02A.9901181752170.21426-100000>
