1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Oinktube/install/deleteOrphanFolders.php
Daniel Neto 59235e20f3 Update
2024-12-19 18:21:09 -03:00

40 lines
989 B
PHP

<?php
//streamer config
require_once '../videos/configuration.php';
if (!isCommandLineInterface()) {
return die('Command Line only');
}
$basePath = getVideosDir();
// Ensure the directory exists
if (!is_dir($basePath)) {
die("Directory does not exist: $basePath\n");
}
// Scan the base directory
$folders = scandir($basePath);
// Loop through each item in the directory
foreach ($folders as $folder) {
// Skip special directories "." and ".."
if ($folder === '.' || $folder === '..') {
continue;
}
// Build the full path
$fullPath = $basePath . $folder;
// Check if it's a directory and starts with "v_" or "video_"
if (is_dir($fullPath) && (str_starts_with($folder, 'v_') || str_starts_with($folder, 'video_'))) {
$video = Video::getVideoFromFileNameLight($folder);
if(empty($video)){
$command = "rm -R {$basePath}$folder";
echo $command.PHP_EOL;
exec($command);
}
}
}
?>