我想知道通过批处理脚本删除了多少文件。我找到了一个脚本并对其进行了修改,但它不起作用。任何想法如何解决它。
set-location d:\testing -ErrorAction stop # Change directory
$files = get-childitem -File # Get all
the files in this directory
$folders = get-childitem -directory # Get all
the folders in this directory
$count = ($files|measure).count #
($files|measure).count gives how
# many files
are in this collection.
$countfo = ($folders|measure).count #
($files|measure).count gives how
# many files
are in this collection.
Start-Sleep -s 5
write-host "There are $($count) files to be deleted." # Write
that to the screen.
$files | remove-item # remove
the files
write-host "There are $($countfo) folders to be deleted." # Write
that to the screen.
$folders | remove-item # remove
the files
$files = get-childitem -File # Get all
the files in this directory
# after the
delete to find out how
# how many
remained.
$folders = get-childitem -directory # Get all
the folders in this directory
# after the
delete to find out how
# how many
remained.
$count2 = ($files|measure).count #
$countfinal = $count-$count2
$countfo2 = ($folders|measure).count
$countfofinal = $countfo-$countfo2
write-host "$($count2) files remained. " -NoNewline #
write-host "$($countfinal) files were deleted. " #
write-host "$($countfo2) folders remained. " -NoNewline #
write-host "$($countfofinal) folders were deleted. " #
Start-Sleep -s 5