Friday, March 17, 2006

We got some opencms mysql dump (from an windows machine) and all tables
are created with Uppercase Chars but on our db server (debian stable ) mysql creates
al database files (thouse under /var/lib/mysql/exampledb ) with small chars
So i wrote 2 scripts for converting the files

#cd /var/lib/mysql/exampledb

create an script with this content

cat upercase.sh
#!/bin/bash
for i in *.myi *.frm *.myd
do
echo $i
mv $i `echo $i | tr "[a-z]" "[A-Z]"`
done
run it

sh upercase.sh

then create another perl script
#vi rename.pl

with this content
#!/usr/bin/perl
foreach $name ( @ARGV ) {
@splitedname = split(/\./, $name);
#print "@splitedname\n";
$filename = $splitedname[0];
$extension = "frm";
$newname = "$filename.$extension";
# $newname =~ tr/A-Z/a-z/;
print "$name becomes $newname\n";
rename ($name, $newname) if ($newname ne $name );
}
and run it

#perl rename.pl *.FRM


ps: it was wrote in rush so i know it can be done better :)



::()::::()::::()::::()::::()::

No comments: