我试图这样做但没有用,有什么想法吗?
if(Test-Path ~\desktop){
$bigfiles = Get-ChildItem ~\desktop -force -Include *.* | Where-Object {$_.Length -gt 10GB}
if{$bigfiles -gt 10GB){
echo "You have big files"
}
}
这是错误:
Cannot compare "C:\Users\mario\Desktop\AngelinaJolie_photo_in_4k.jpg" because it is not IComparable.
At line:7 char:8
+ if($bigfiles -gt 10GB){
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NotIcomparable
如果没有结果,FileInfo
则$ bigfiles为$ null;如果有一个结果,则为$ null ,否则为FileInfo
s的数组。您可以使用以下方法检查结果
if($bigfiles) { ... }
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句