:: 删除E盘根目录下指定文件夹之外的其亏基岁他文件夹和文件销睁
:: test.txt里保存有不带路径的指定文件夹名,一行一条记录
:: 代码和test.txt必须放在E盘之锋燃外的分区
for /f "delims=" %%i in ('dir /a /b e:\') do (
set flag=
for /f "delims=" %%j in (test.txt) do if /i "%%i"=="%%j" set flag=1
if not defined flag del /a /f "e:\%%i" 2>nul||rd /s "e:\%%i" 2>nul
)
pause
'删除“D:\敏洞返yy”目录桥饥下的所颤敏有文件及文件夹Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("d:\yy\*.*"), DeleteReadOnly
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" &strComputer &"\root\cimv2")
Set colSubfolders2 = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" &"d:\yy" &"'} " _
&"Where AssocClass = Win32_Subdirectory " _
&"ResultRole = PartComponent")
For Each objFolder2 in colSubfolders2
objFSO.deleteFolder objFolder2.name , DeleteReadOnly
Next
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)