当发生错误时跳过 [英] Skip when error occurs

查看:204
本文介绍了当发生错误时跳过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在批(CMD)以下的code:

i have the following code in batch (cmd):

for /f "delims=" %%f in ('dir /b /s Example') do (
command
if %errorlevel%==1 (
command
SKIP
)
command
)

编辑:
为了让事情更清楚:
FOR / F ... 搜索名为样本,并循环到搜索不止一个目录的目录。
第一个命令是删除命令,它会删除目录中的所有文件。
命令发生错误时出现这种情况,是该写的错误一些信息到一个文本文件中的回声命令。
现在孔跳过的事情;有时,这些文件不能因为删除拒绝访问该文件正在由...使用。通常情况下,会发生什么,如果有不跳过的东西,它只是停止命令挂起。所以,我想要做的,是prevent这种情况的发生。另外,我想使用类似跳过,因此它可以跳过该文件并继续反正。所以我觉得这个命令需要在删除命令进行输送。

To make things more clear: for /f... searches for a directory called 'Example' and loops to search for more directories than one. the first command is a delete command, it deletes all files in the directory. the command that happens when an error occurs, is a echo command which writes some info about the error to a text file. now the hole skip thing; sometimes, the files can't be deleted because of access denied or this file is in use by.... Normally, what would happen if there weren't a skip thing, it would just stop the command and hang. So, what i want to do, is prevent this from happening. Alternatively, i want to use something like skip, so it can skip the file and continue anyways. So i think this command needs to be piped in the delete command.

我希望它现在清楚了。

先谢谢了。

推荐答案

喜欢这个?

for /f "delims=" %%f in ('dir /b /s Example') do (
  command
  if not errorlevel 1 (
    command-for-success
  ) else (
    command-for-error
  )
)

这篇关于当发生错误时跳过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆