I'm trying to delete everything with less than 2kB file size and am using the following code:
Get-ChildItem $path -Filter *.html -Recurse -File |
? {$_.Length -lt 2000} |
% {Remove-Item $_.FullName}
I keep getting errors like this:
Remove-Item : Cannot retrieve the dynamic parameters for the cmdlet.
The specified wildcard character pattern is not valid: 07 somefilename
filename.mp3
At line:1 char:66
+ ... -Recurse -File | ? {$_.Length -lt 2000} | % {Remove-Item $_.FullName}
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item -LiteralPath $_.FullName