Board logo

标题: [已解决]如何屏蔽for循环查找文件的信息 [打印本页]

作者: easonL     时间: 2008-5-26 13:36    标题: [已解决]如何屏蔽for循环查找文件的信息

for /f "delims=" %%a in ('dir/b/a-d "%root%\*.log"') do (
   set "str=%%~nxa"
   set "str=!str:~0,6!"
   if !str! leq %yy% (del/q "%root%\%%~nxa") else (
      if not exist "%root%\!str!\" md "%root%\!str!"
      move "%root%\%%~nxa" "%root%\!str!"
    )
)

在以上这段指令里面,意思是查找目录下的log文件,然后进行处理
现在的问题是,如果没有找到文件,也就是log文件不存在,会提示:
D:\batch>delFile
File Not Found
Press any key to continue . . .

我想将提示信息“File Not Found”屏蔽掉,使他不输出,应该怎么办?
谢谢

[ Last edited by easonL on 2008-5-26 at 02:22 PM ]
作者: tao0610     时间: 2008-5-26 13:48
2>nul
作者: easonL     时间: 2008-5-26 13:58


  Quote:
Originally posted by tao0610 at 2008-5-26 01:48 PM:
2>nul

呵呵,谢谢您的解答!我知道用这个指令,可是不知道写在哪里,试了几下,还是不对,请详细告诉我添加的位置,谢谢!

拜托了
作者: moniuming     时间: 2008-5-26 14:02
for /f "delims=" %%a in ('dir/b/a-d "%root%\*.log" 2>nul') do (
作者: easonL     时间: 2008-5-26 14:11


  Quote:
Originally posted by moniuming at 2008-5-26 02:02 PM:
for /f "delims=" %%a in ('dir/b/a-d "%root%\*.log" 2>nul') do (

这样添加会出错,错误信息是:
2> was unexpected at this time.

不知道何解?
作者: moniuming     时间: 2008-5-26 14:14
忘记加取义符了
for /f "delims=" %%a in ('dir/b/a-d "%root%\*.log" 2^>nul') do (
作者: easonL     时间: 2008-5-26 14:18


  Quote:
Originally posted by moniuming at 2008-5-26 02:14 PM:
忘记加取义符了
for /f "delims=" %%a in ('dir/b/a-d "%root%\*.log" 2^>nul') do (

恩,好了呢!谢谢,我现在去看下取义符的用法,呵呵!
嘿,菜鸟(对自己),继续加油,学习!!