求全盘删除指定文件夹命令 vbs或bat都行
展开全部
批处理代码:
@echo off
for /f %%i in ('wmic logicaldisk where "DriveType=3" get DeviceID^|more +1') do for /f "delims=" %%j in (1.txt) do for /f "delims=" %%k in ('wmic fsdir where "drive='%%i' and filename='%%j'" get name^|more +1') do set tp=%%k&call rd /q /s "%%tp%%">nul 2>nul
echo 全部清除完成!&pause
VBS代码:
Set Fso = CreateObject ("Scripting.FileSystemObject")
Set TxtFl = fso.OpenTextFile ("1.txt",1)
i=0
Do While TxtFl.AtEndofStream<>True
ReDim Preserve Fns(i)
Fns(i)=UCase (Trim (TxtFl.ReadLine))
i=i+1
Loop
for each Drive in Fso.Drives
If Drive.DriveType = 2 Then
FindAllFolder (Drive.RootFolder)
End if
next
Sub FindAllFolder (FdrPath)
On Error Resume next
Set Fdr = Fso.GetFolder (FdrPath)
For Each SubFdr In fdr.SubFolders
If Err.Number=0 Then
For Each Fn In Fns
If UCase (SubFdr.Name)=Fn Then
Fso.DeleteFolder SubFdr.Path,true
End If
Next
FindAllFolder (SubFdr.Path)
End If
Next
On Error Goto 0
End Sub
MsgBox "全部清除完成!"
把bat或vbs放到1.txt文件同一个目录里。运行。都能实现你的要求。
@echo off
for /f %%i in ('wmic logicaldisk where "DriveType=3" get DeviceID^|more +1') do for /f "delims=" %%j in (1.txt) do for /f "delims=" %%k in ('wmic fsdir where "drive='%%i' and filename='%%j'" get name^|more +1') do set tp=%%k&call rd /q /s "%%tp%%">nul 2>nul
echo 全部清除完成!&pause
VBS代码:
Set Fso = CreateObject ("Scripting.FileSystemObject")
Set TxtFl = fso.OpenTextFile ("1.txt",1)
i=0
Do While TxtFl.AtEndofStream<>True
ReDim Preserve Fns(i)
Fns(i)=UCase (Trim (TxtFl.ReadLine))
i=i+1
Loop
for each Drive in Fso.Drives
If Drive.DriveType = 2 Then
FindAllFolder (Drive.RootFolder)
End if
next
Sub FindAllFolder (FdrPath)
On Error Resume next
Set Fdr = Fso.GetFolder (FdrPath)
For Each SubFdr In fdr.SubFolders
If Err.Number=0 Then
For Each Fn In Fns
If UCase (SubFdr.Name)=Fn Then
Fso.DeleteFolder SubFdr.Path,true
End If
Next
FindAllFolder (SubFdr.Path)
End If
Next
On Error Goto 0
End Sub
MsgBox "全部清除完成!"
把bat或vbs放到1.txt文件同一个目录里。运行。都能实现你的要求。
展开全部
@echo off
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\ (
for /f "delims=" %%b in (1.txt) do (
echo 处理中……
for /f "delims=" %%c in ('dir /ad /b "%%a:\%%b" 2^>nul') do (if exist "%%a:\%%c" rd /s /q "%%a:\%%c" >nul 2>nul)
for /f "delims=" %%c in ('dir /ad /s /b "%%a:\%%b" 2^>nul') do (if exist "%%~fc" rd /s /q "%%~fc" >nul 2>nul)
)))
批处理在1.txt文件夹运行,1.txt不能保存在要删除的文件夹里面。
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\ (
for /f "delims=" %%b in (1.txt) do (
echo 处理中……
for /f "delims=" %%c in ('dir /ad /b "%%a:\%%b" 2^>nul') do (if exist "%%a:\%%c" rd /s /q "%%a:\%%c" >nul 2>nul)
for /f "delims=" %%c in ('dir /ad /s /b "%%a:\%%b" 2^>nul') do (if exist "%%~fc" rd /s /q "%%~fc" >nul 2>nul)
)))
批处理在1.txt文件夹运行,1.txt不能保存在要删除的文件夹里面。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
@echo off
echo 清理中^^^^^^^^^
del /f /s /q 太平公主等文件夹的路径\*.*
rd 太平公主等文件夹的路径 /s /q
echo 清除完成!
echo. & exit
pause
比如要删除C盘下的123(假设)目录,以及123里的全部文件可以将上面的语句改成如下:
-------------------------------
@echo off
echo 清理中^^^^^^^^^
del /f /s /q c:\123\*.*
rd c:\123 /s /q
echo 清除完成!
echo. & exit
pause
----------------------------------
将这些语句存到一个文本文档里改名成后缀为.bat的批处理文件就可以了
echo 清理中^^^^^^^^^
del /f /s /q 太平公主等文件夹的路径\*.*
rd 太平公主等文件夹的路径 /s /q
echo 清除完成!
echo. & exit
pause
比如要删除C盘下的123(假设)目录,以及123里的全部文件可以将上面的语句改成如下:
-------------------------------
@echo off
echo 清理中^^^^^^^^^
del /f /s /q c:\123\*.*
rd c:\123 /s /q
echo 清除完成!
echo. & exit
pause
----------------------------------
将这些语句存到一个文本文档里改名成后缀为.bat的批处理文件就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询