isFile() == true ) { $punch_id = str_replace( '.' . pathinfo( $file->getFileName(), PATHINFO_EXTENSION ), '', $file->getFilename() ); $plf->getById( $punch_id ); if ( $plf->getRecordCount() == 0 || ( $plf->getRecordCount() == 1 && (bool)$plf->getCurrent()->getHasImage() == false ) ) { echo 'Path+File: ' . $file->getPathName() . ' File: ' . $file->getFilename() . ' Punch ID: ' . $punch_id . ' File mTime: ' . TTDate::getDate( 'DATE+TIME', filectime( $file->getPathName() ) ) . "\n"; Debug::Text( 'Path+File: ' . $file->getPathName() . ' File: ' . $file->getFilename() . ' Punch ID: ' . $punch_id . ' File mTime: ' . TTDate::getDate( 'DATE+TIME', filectime( $file->getPathName() ) ), __FILE__, __LINE__, __METHOD__, 10 ); echo ' Punch does not exist, or does not have image, deleting orphaned image file: ' . (int)$plf->getRecordCount() . "\n"; Debug::Text( ' Punch does not exist, or does not have image, deleting orphaned image file: ' . (int)$plf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10 ); if ( $dry_run == false ) { @unlink( $file->getPathName() ); $i++; } } else { echo ' Punch still exists, leaving image alone. Punch ID: ' . $punch_id . "\n"; Debug::Text( ' Punch still exists, leaving image alone. Punch ID: ' . $punch_id, __FILE__, __LINE__, __METHOD__, 10 ); } } } echo "Deleted Punch Images: " . $i . "\n"; } echo "Done...\n"; Debug::WriteToLog(); Debug::Display(); ?>