load(DDBASE.'/DDsys.xml'); $dataSets = $ddSys->getElementsByTagName('VI'); foreach ($dataSets as $VI) { $id = $VI->getElementsByTagName('NAME')->item(0)->nodeValue; $main = array(); $index = array(); $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue; foreach (glob($location."*.nc.gz") as $granule) { $cmd = 'stat --printf="%s" '. $granule; $file = basename($granule,".nc.gz"); $index[$file] = exec($cmd); } $main[substr($location,strlen(DDBASE))] = $index; file_put_contents("GRANULES/$id.json", json_encode($main)); } ?>