This should serve your purposes
<?php
//Make sure this is the path to your image directory
$path = "/www/something/images";
chdir($path);
$dir = dir(".");
$dir->rewind();
while ($file=$dir->read()) {
if (!ereg("_t", $file) && !is_dir($file)) {
$filelist[] = $file;
}
}
$dir->close();
while (list ($key, $value) = each ($filelist)) {
$imagename = explode(".", $value);
$strippedimagename = $imagename[0];
$result = mysql_query("INSERT into tablename (imagename) VALUES ('$strippedimagename')", $db);
}
?>
-Freddydoesphp