//获取unix时间戳的当前时间
$addtime=date("ymd",time());
//创建文件夹
$testdir="./python/out/dada".$addtime."/";
if(file_exists($testdir)):
else:
mkdir($testdir,0777);
endif;
function getDirContent($path){
if(!is_dir($path)){
return false;
}
$arr = array();
$data = scandir($path);
foreach ($data as $value)
{
if($value != '.' && $value != '..')
{
$arr[] = $value;
}
return $arr;
}
}
function del_dir($dir) {
if (!is_dir($dir)) {
return false;
}
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
is_dir("$dir/$file") ? del_dir("$dir/$file") : @unlink("$dir/$file");
}
}
if (readdir($handle) == false) {
closedir($handle);
@rmdir($dir);
}
}
$wenjia=getDirContent("./python/out/");
foreach($wenjia as $k)
{
if($k!="dada".$addtime){
$unlik="./python/out/".$k;
del_dir($unlik);
}
}