我有以下批处理代码(cmd):
for /f "delims=" %%f in ('dir /b /s Example') do (
command
if %errorlevel%==1 (
command
SKIP
)
command
)
编辑:
为了让事情更清楚:
for/f...
搜索名为“Example”的目录并循环搜索多个目录。
第一个 command
是删除命令,它删除目录中的所有文件。
发生错误时发生的 command
是一个 echo
命令,它将有关错误的一些信息写入文本文件。
现在是洞 skip
的东西;有时,由于access denied
或this file is in use by...
,文件无法删除。通常情况下,如果没有跳过的东西会发生什么,它只会停止命令并挂起。所以,我想做的是防止这种情况发生。或者,我想使用 skip
之类的东西,这样它就可以跳过文件并继续。所以我认为这个命令需要通过管道传输到 delete
命令中。
我希望现在一切都清楚了。
提前致谢。
最佳答案
像这样?
for /f "delims=" %%f in ('dir /b /s Example') do (
command
if not errorlevel 1 (
command-for-success
) else (
command-for-error
)
)
关于windows - 发生错误时跳过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1966671/