// DELETE THUMBNAILS - USE TIME-SAVING UNIX COMMANDS INSTEAD
$errorMsg = exec("cd $thumbLoc 2>&1"); // YOU HAVE TO SPLIT THEM UP, "cd" THROWS A DIFFERENT ERROR THAN WHAT "rm" WILL CATCH
if (preg_match('/no such/i', $errorMsg)) {
$this->isSuccessful = false;
$this->setErrorArray(array('action' => "Cannot find \"$thumbLoc\": $errorMsg"));
}
if ($this->isSuccessful) $errorMsg = exec("cd $thumbLoc 2>&1 ; rm * 2>&1");
if ($this->isSuccessful && preg_match('/lstat/i', $errorMsg)) {
$this->isSuccessful = false;
$this->setErrorArray(array('action' => "Cannot delete $section thumbnails from \"$thumbLoc\": $errorMsg"));
}
// DELETE IMAGES - USE TIME-SAVING UNIX COMMANDS INSTEAD
if ($this->isSuccessful) $errorMsg = exec("cd $locationPath 2>&1");
if ($this->isSuccessful && preg_match('/no such/i', $errorMsg)) {
$this->isSuccessful = false;
$this->setErrorArray(array('action' => "Cannot find \"$locationPath\": $errorMsg"));
}
if ($this->isSuccessful) $errorMsg = exec("cd $locationPath 2>&1 ; rm * 2>&1");
if ($this->isSuccessful && preg_match('/lstat/i', $errorMsg)) {
$this->isSuccessful = false;
$this->setErrorArray(array('action' => "Cannot delete ${section}s from \"$locationPath\": $errorMsg"));
}
This is an honest question. I am having to come up with script (this script is in a class method) that will delete up to several hundred 100K image files in a single folder at one time and, of course, be EXTREMELY fast in doing it (hence, no looping).
However, I'm not sure if it's a good idea to do exec("cd..") and then exec("cd.. ; rm *") behind it, but it is the only way I can ensure the right content is deleted from the right folder.
What do you all say?
Thanx
Phil