main->filesPath . DS . $name; $dstPath = $dir . DS . $name; rename($srcPath, $dstPath); }; break; case '-d': case '--delete': $func = function($name) { echo $name . PHP_EOL; $srcPath = Core::getConfig()->main->filesPath . DS . $name; unlink($srcPath); }; break; default: die('Unknown action' . PHP_EOL); } $names = []; foreach (PostModel::getAll() as $post) { $names []= $post->getName(); } $names = array_flip($names); $config = Core::getConfig(); foreach (glob(TextHelper::absolutePath($config->main->filesPath) . DS . '*') as $name) { $name = basename($name); if (!isset($names[$name])) { $func($name); } }