View Full Version : Moving from Windows to Unix, Change filenames to lowercase!!
Hello,
I have acqired a small hosting company which used to host their sites on windows servers. As you know filenames are not case sensitive in windows.
Now that I am trying to move static websites (those who have not used any dynamic asp pages) I see that most of images do not load and some links do not work anymore.
I am forced to edit files one by one and change all file names to lowercase in both html files and files themselves.
Is there a program which opens html files and converts all file references to lowercase letters?
I have about 25 of these sites , some of them have used more than 100 image files in more than 20 pages.
Regards,
Mac
akashik 11-09-2002, 11:20 AM Originally posted by wmac
Is there a program which opens html files and converts all file references to lowercase letters?
For the files themselves I found this:
http://www.geocities.com/lupas2000/
I seems to allow you to batch change files from upper to lowercase, or the other way around - amongst other things. It might help.
Greg Moore
Greg, Thank you.
Also Windows Commander (ghisler.com) has an option to convert files to lowercase when uploading.
I upload files to my ftp server with that option to convert them to lowercase.
Converting those references inside files is very hard. I wish I can find a software for a reasonable price.
Mac
El Nino 11-09-2002, 12:38 PM I know CuteFTP has the option to force filenames to lowercase when uploading/downloading
MarkIL 11-09-2002, 12:46 PM How about hiring someone (like me :)) to write a program that does that?
Al Nadeem 11-09-2002, 05:11 PM here is a PHP script to do that:
<?php
/********************************************************************************/
/* FILE NAME CASE CHANGER */
/* PROGRAMMER : Vipin Chandran */
/* E-Mail : vipin1973@hotmail.com */
/* Convert the file name case into lower case in a folder and sub folders */
/********************************************************************************/
/* Scan root directory */
/* ******************* */
if(!isset($dir_arr) && isset($root))
{
$main_dir = stripslashes($root);
if(!($handle=@opendir($main_dir)))
{
print "<DIV align=center><h5>PLEASE SPECIFY A VALID DIRECTORY</h5></div>";
exit;
}
$i=1;
$dir_arr=array();
echo "THE FOLLOWING FILENAMES WERE CONVERTED TO LOWERCASE<br>";
echo "********************************<br>".$main_dir."<br>********************************<br>";
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
/* Check if the file is a directory and if so, store it in an array */
/* **************************************************************** */
if(is_dir($main_dir."\\".$file))
{
array_push($dir_arr,$file);
}
echo "$i=>\"$file\",<br>";
$file2 = strtolower($file);
if(!(@rename($main_dir."\\".$file,$main_dir."\\".$file2)))
{
Print "<br>Rename Failed<br>";
}
$i++;
}
}
closedir($handle);
}
/* Traverse through the subfolders stored in the array */
/* **************************************************** */
$x=0;
while($x<count($dir_arr))
{
$main_dir = addslashes(stripslashes($root)."\\".$dir_arr[$x]);
if(!($handle=@opendir($main_dir)))
{
print "<DIV align=center><h5>CANNOT OPEN DIRECTORY</h5></div>";
exit;
}
$i=1;
echo "********************************<br>".stripslashes($main_dir)."<br>********************************<br>";
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
if(is_dir($main_dir."\\".$file))
{
$dir_arr[]=$dir_arr[$x]."\\".$file;
}
echo "$i=>\"$file\",<br>";
$file2 = strtolower($file);
if(!(@rename($main_dir."\\".$file,$main_dir."\\".$file2)))
{
Print "<br>Rename Failed<br>";
}
$i++;
}
}
closedir($handle);
$x++;
}
?>
Shyne 11-09-2002, 06:18 PM Wouldn't it be easier to just create symbolic links between the lower and upper case files?
achost_ca 11-09-2002, 06:32 PM i can see it being easier, but it can cause quite an organizational mess if you ever change it too much, or if the owner of the site your hosting doesn't fully understand what you did.
Everyone, We currently know how to convert filenames to lowercase,
Just Find someway to convert references in html files
Mac
PHBPendragon 11-09-2002, 10:27 PM tr
tr "[:lower:]" "[:upper:]" < file1
will do the whole file.
To do specifics a regex should get it if there are unique identifiers.
Shyne 11-09-2002, 11:12 PM He wants you to the write the script for him.
Shyne
No, I want don't to bother anyone :) I myself have been a programmer for abouy 17-18 years. :)
But I wish I can do that with a ready made software instead of spending 10-20 hours to develop my own windows application. (I normally do it using VC++ or Delphi)
Anyway PHBPendragon's idea is interesting but it may corrupt scripts :)
If I can not find something I will try to develop an application myself.
Mac
TDMWeb 11-11-2002, 06:41 AM HTML Rename from xlanguage.com renames the files and all the internal references as well, see http://xlanguage.com/products/rename.htm
It misses stuff in javascript I think but apart from that is fine.
Excellent utility, wouldn't be without it.
Great!
Chris, Thank you very much.
You saved me a lot of time. Last time I spent about 8 hours to correct html files of a single website.
Thank you again man! :)
Mac
TDMWeb 11-11-2002, 08:00 AM Thank you again man!
No worries. Us Delphi guys gotta stick together!
Originally posted by TDMWeb
No worries. Us Delphi guys gotta stick together!
;)
|