重复文件查找:https://download.csdn.net/download/rerere__rereredd/9745723 Duplicate Cleaner Pro 4.0.4中英文多语言 注册版
1.FilelistCreator --- 导出某个盘的文件,导出成excel表格,工具下载:https://www.cnblogs.com/onelikeone/p/11965279.html
2.针对路径,添加引号,添加引号方法参考:https://www.cnblogs.com/onelikeone/p/11965914.html
3.excel表格筛选要删除的文件,标注颜色,复制路径 到bat脚本
删除指定文件.bat
@echo off chcp 65001 DEL /F/S/Q "D:\workspace\项目收集【】\AndroidCode原包名\闹钟\readme.txt" DEL /F/S/Q "D:\workspace\项目收集【】\AndroidCode原包名\闹钟\ZZDeskClock\ZZDeskClock\.classpath"
4.最后删除空文件夹
最后删除空文件夹.bat
@echo off @REM https://blog.csdn.net/XavierDarkness/article/details/84785482 color 0A for /f "delims=" %%a in ('dir . /b /ad /s ^|sort /r' ) do rd /q "%%a" 2>nul pause
改进版:
中文乱码问题参考:https://www.cnblogs.com/onelikeone/p/11965839.html
@echo off @REM 删除空目录 color 0A for /f "delims=" %%a in ('dir . /b /ad /s ^|sort /r') do ( rd /q "%%a" 2>nul && echo 空目录"%%a" 成功删除!>>log ) pause
VBA脚本:
路径是否存在,是否应该添加判断? 如果路径有空格,是否需要添加引号?
Option Explicit Option Compare Text Sub 根据文件路径删除文件() '声明语句 Dim i As Integer Dim j As Integer Dim sLength As Integer '源工作表总行数 Dim sSheet As Worksheet '源工作表 Dim sValue As String Dim sPath As String Dim MyFile As Object '赋值语句 Set sSheet = Worksheets("Sheet2") '第一个工作表 '获取工作表总行数 sLength = sSheet.Cells(Rows.Count, "A").End(xlUp).Row '打印总行数 Debug.Print "source sheet length:" & sLength For i = 2 To sLength '第一行是标题行 sValue = sSheet.Cells(i, "A").Value On Error Resume Next Set MyFile = CreateObject("Scripting.FileSystemObject") '判断文件是否存在,若存在则删除 If MyFile.fileExists(sValue) = True Then Debug.Print "删除:"; sValue '后面true,表示强制删除,包括只读文件 MyFile.DeleteFile sValue, True Set MyFile = Nothing End If Next i Debug.Print "完成!!!" End Sub