Answers:
(2)
使用以下搜索表达式:
name:~"*(2)*"
笔记:
~
是文字字符串指示符,以下内容必须匹配整个文件名
根据您的需求filename:
可能会比name:
之前:
后:
我建议使用PowerShell脚本:
(1)
给定起始文件夹的所有带有BaseName 尾随的文件。更改Push-Location
以适合您的起始文件夹,使用扩展名保存文件.ps1
并执行它。
## Q:\Test\2017\07\15\SU_1230033.ps1
## inspired by http://n3wjack.net/2015/04/06/find-and-delete-duplicate-files-with-just-powershell/
Push-Location "D:\"
Get-ChildItem "* (1).*" -Recurse -File | ForEach-Object {
$BaseFile = (Join-Path $_.Directory ($_.BaseName -replace ' ?\(\d+\)'))+"*$($_.Extension)"
Get-ChildItem $BaseFile | Get-FileHash | Group-Object Hash | Where { $_.Count -gt 1 } |
ForEach-Object {$_.Group | Select-Object -Skip 1 } | Remove-Item -Confirm
}
PopD
要获取文件的dir列表,请使用此简化脚本:
Push-Location "D:\"
Get-ChildItem "* (1).*" -Recurse -File | ForEach-Object {
$BaseFile = (Join-Path $_.Directory ($_.BaseName -replace ' ?\(\d+\)'))+"*$($_.Extension)"
Get-ChildItem $BaseFile
}
PopD