file); } $count = 0; foreach (File::files(public_path('build/assets')) as $file) { if (! in_array($file->getFilename(), $filesUsed)) { unlink($file->getPathname()); $count++; } } $this->info($count.' files deleted.'); } catch (Exception $e) { $this->error($e->getMessage()); } } }