我想写一个批处理脚本删除子文件夹(egc:\ temp \ root \ students \ students23435)它有一个名称的名称(其父母)文件夹(egc:\ temp \ root \ students)。通过批处理文件删除与findstr的特定子文件夹
粗体如下所示的文件夹应被删除:
C:\ TEMP \根\学生
C:\ TEMP \根\学生\ students23435
c:\ temp \ root \ students \ students9875
c:\ temp \ root \ students \ 1234
个C:\ TEMP \根\教师
C:\ TEMP \根\教师\ teachers12345
C:\ TEMP \根\教师\ teachers898
@echo off
rem pushd "c:\temp\root\"
for /F "tokens=*" %%I in ('dir /a:d-s-h /b ^| findstr /B /I /C:"students" /C:"teachers"') do (
echo Removing Directory "%%I"
rmdir /s /q "%%I")
rem popd
你能帮我解决这个问题吗?
非常感谢。
祝您有美好的一天。
不明白。 什么是“@Dir”的替代? 如何跳过删除父文件夹(例如c:\ temp \ root \ teachers,c:\ temp \ root \ students)? – PNouma2121
将'C:\ Symbols'更改为'c:\ temp \ root'并运行它。 – 2016-07-28 06:09:10