/** * Remove unused uploaded Files with a scheduler task * * This task can clean up unused uploaded files * with powermail from your server * * @param string $uploadPath Define the upload Path * @return void */ public function cleanUnusedUploadsCommand($uploadPath = 'uploads/tx_powermail/') { $usedUploads = $this->getUsedUploads(); $allUploads = BasicFileUtility::getFilesFromRelativePath($uploadPath); $removeCounter = 0; foreach ($allUploads as $upload) { if (!in_array($upload, $usedUploads)) { $absoluteFilePath = GeneralUtility::getFileAbsFileName($uploadPath . $upload); if (filemtime($absoluteFilePath) < time() - $this->delta) { unlink($absoluteFilePath); $removeCounter++; } } } $this->outputLine('Overall Files: ' . count($allUploads)); $this->outputLine('Removed Files: ' . $removeCounter); }