简易清除DW备注文件(PHP版)

<?php
function delDwFile($path) {
	global $i;
	if (!is_dir($path)) {
		return false;
	} else {
		$d = dir($path);
	}

	while(false != ($entry = $d->read()))
	{
		$currentPath = $path. '/'.$entry ;
		if ($entry == '.' || $entry == "..") {
			continue;
		}
		
		if (is_dir($currentPath)) {
			delDwFile($currentPath);
		}
		if (is_dir($currentPath) && substr($currentPath,-6) == '_notes' && @rmdir($currentPath)) {
			echo(++$i. "\t". $currentPath."\n");
		} else if (is_file($currentPath) && basename($currentPath) == 'dwsync.xml' && @unlink($currentPath)) {
			echo(++$i. "\t". $currentPath."\n");
		} 
	}
	$d->close();
}

$i = 0 ;
$path = 'D:/opendev/';
delDwFile($path);
echo("Notice: DEL DW File {$i} ");

你可能感兴趣的:(PHP,清除,DW备注,dwsync.xml,_notes)