I was actually thinking that the cron could run a script like this. It seems to be capable of scanning the files relatively fast. Basically what it would do is identify each different word and stores it in the database with the file ID and line number. I figure this will create a large database eventually, but if I split it seperate tables alphabetically, I think it might be ok. What do you guys think? Would it destroy the database? [code]$dir="00"; $linex=0; $all_words=array(); $handle=opendir($dir); $id_link=mysql_connect("*****", "******", "******"); mysql_select_db("******"); while (false!==($file=readdir($handle))) { if ($file!="."&&$file!="..") { $sql="SELECT * FROM `files` WHERE `filename` = '{$file}'"; if (mysql_num_rows(mysql_query($sql)) == 0) { echo $file."<hr>"; $conts=file_get_contents("{$dir}/{$file}"); $lines=explode("\n", $conts); foreach ($lines as $line) { $linex++; $line=trim($line); $words=explode(" ", $line); foreach ($words as $word) { $word=preg_replace("@<<[^>]+>>@i", "", $word); $word=preg_replace("@[._(),*$!?'\[\]\"]+@i", "", $word); $word=trim($word); if (!empty($word)) { $word=strtolower($word); if (!isset($all_words[$word])) { $all_words[$word]="{$linex}"; } else { $all_words[$word].=",{$linex}"; } } } } $sql="INSERT INTO `files` (`filename`) VALUES ('{$file}')"; $query=mysql_query($sql); $fileID=mysql_insert_id(); $ix=0; $ux=0; ksort($all_words); foreach ($all_words as $key=>$word) { $sql="SELECT * FROM `words` WHERE `WORD` = '{$key}'"; if (mysql_num_rows(mysql_query($sql)) > 0) { $updates[$ux]="UPDATE DELAYED `words` SET `MATCHES` = CONCAT(`MATCHES`, '{$fileID},{$word};') WHERE `WORD` = '{$key}'"; } else { $inserts[$ix]="('{$key}', '{$fileID},{$word};')"; $ix++; } } if ($ix > 0) { //Run INSERT command. $insert="INSERT INTO `words` (`WORD`, `MATCHES`) VALUES "; $insert_line=implode(",", $inserts); $insert.=$insert_line; if (!mysql_query($insert)) { echo mysql_error(); echo "<hr>{$insert}"; } } break; } } } mysql_close($id_link); [/code]