本帖最后由 CrLf 于 2013-3-12 00:39 编辑
文件又多又大的话,用 vbs 会快很多- Const [路径]="." '这里设置路径
- Const [重复次数]="1" '代表重复达到多少次就删除
- Set fso = CreateObject("scripting.filesystemobject")
-
- For Each file In fso.GetFolder([路径]).Files
- If LCase(fso.GetExtensionName(file)) = "txt" Then
- If reTest(fso.OpenTextFile(file).ReadAll) Then
- file.Delete
- End If
- End If
- Next
-
- Function reTest(text)
- Set re = New RegExp
- re.Global = True
- re.Pattern = "\n(\S+)(?:(?:\n.*)?\n\1){" & [重复次数] & ",}\n"
- reTest = re.Test(vbCrLf & text & vbCrLf)
- End Function
复制代码
|