bat 批处理,循环删除文件,怎么用for 循环写? 5
del/f/q/a"C:\DocumentsandSettings\hzuser01\MyDocuments\*.xls"del/f/q/a"C:\Documentsan...
del /f /q /a "C:\Documents and Settings\hzuser01\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser02\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser03\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser04\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser05\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser06\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser07\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser08\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser09\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser10\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser11\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser12\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser13\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser14\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser15\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser16\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser17\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser18\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser19\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl12.HZ\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl13.HZ\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl14.HZ\My Documents\*.xls"
如题怎么用FOR 循环删除?
或者有while 循环的写法?
这么写对不对?
for %%d in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,wl,wl12.HZ,wl13.HZ,wl14.HZ)
do (del /f /q /a "C:\Documents and Settings\hzuser%%d\My Documents\*.xls")
有没有更好的写法? 展开
del /f /q /a "C:\Documents and Settings\hzuser02\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser03\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser04\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser05\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser06\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser07\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser08\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser09\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser10\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser11\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser12\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser13\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser14\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser15\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser16\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser17\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser18\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuser19\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl12.HZ\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl13.HZ\My Documents\*.xls"
del /f /q /a "C:\Documents and Settings\hzuserwl14.HZ\My Documents\*.xls"
如题怎么用FOR 循环删除?
或者有while 循环的写法?
这么写对不对?
for %%d in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,wl,wl12.HZ,wl13.HZ,wl14.HZ)
do (del /f /q /a "C:\Documents and Settings\hzuser%%d\My Documents\*.xls")
有没有更好的写法? 展开
1个回答
展开全部
for /l %i in (1,1,9) do del /f /q /a "C:\Documents and Settings\hzuserwl0%%i.HZ\My Documents\*.xls"
for /l %i in (10,1,19) do del /f /q /a "C:\Documents and Settings\hzuserwl%%i.HZ\My Documents\*.xls"
或者删除所有
for /f ”tokens*" %%i in ('dir/ad "c:\Documents and Settings"‘)do del /f /q /a ”c:\Documents and Settings\%%i\My Documents\*.xls"
删除所有可先生成批处理,检查无误后再运行
(for /f ”tokens*" %%i in ('dir/ad "c:\Documents and Settings"^|findstr /i /b hzuser‘)do echo del /f /q /a ”c:\Documents and Settings\%%i\My Documents\*.xls")>deldel.bat
notepad deldel.bat
for /l %i in (10,1,19) do del /f /q /a "C:\Documents and Settings\hzuserwl%%i.HZ\My Documents\*.xls"
或者删除所有
for /f ”tokens*" %%i in ('dir/ad "c:\Documents and Settings"‘)do del /f /q /a ”c:\Documents and Settings\%%i\My Documents\*.xls"
删除所有可先生成批处理,检查无误后再运行
(for /f ”tokens*" %%i in ('dir/ad "c:\Documents and Settings"^|findstr /i /b hzuser‘)do echo del /f /q /a ”c:\Documents and Settings\%%i\My Documents\*.xls")>deldel.bat
notepad deldel.bat
追问
执行不起来啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询