<?php
include_once ('../../../config.php');
include_once ("../path.php");

$folders = scandir($json_instance_path);

echo "<div style='$SCRIPT_STYLE'>";
echo "Cleaning up json_annotations folder for <b>" . strtoupper($instance_name) . "...</b><br><br>";

$i = 0;
foreach ($folders as $f)
{
    $path = $json_instance_path . $f;

    if ($f === '.' || $f === '..'|| !is_dir($path)) continue;
    rmdir($path);
    if ( !is_dir($path) ) {
    	echo "Empty folder ".strtoupper ($f)." has been removed <br>";
        $i++;
    }
    
}
echo $i ." empty folder(s) has been removed";
echo '</div>';