Originally posted by bd540 at 2007-10-10 13:17:
这段代码运行时显示“设备没有准备好”“找不到文件”等信息,如何将这些信息隐藏呢?我把>NUL加了几个地方都提示错误。
for %%a in (Z Y X W ...
这个问题有人问过的
我当时给出了解决办法
其实就是这样的格式:----可以处理含有空格文件名和路径
for "delims=" %%a in (xx) do ( ...... ) >nul 2>nul
...... 代表你要做的一切操作,不论多少行,多少命令都可以的;
那个">nul 2>nul"一定要接在for...do (...) 的最后一个括号 ")" 的后面.
这样可以屏蔽任何信息!
看一个实例:
@echo off
for /f "delims=" %%i in ("%cd%") do (
echo %%i
dir c:\
dir x:\
) >nul 2>nul
Last edited by scriptor on 2007-10-11 at 12:36 AM ]
Originally posted by bd540 at 2007-10-10 13:17:
When this code runs, it displays messages like "Device not ready" and "File not found". How to hide these messages? I added >NUL in several places and got errors.
for %%a in (Z Y X W ...
This question has been asked before.
I gave a solution at that time
Actually, it's in this format:----It can handle file names and paths with spaces
for "delims=" %%a in (xx) do ( ...... ) >nul 2>nul
...... represents all the operations you want to do, no matter how many lines or commands;
That ">nul 2>nul" must be added right after the last parenthesis ")" of for...do (...).
This can suppress any messages!
Here's an example:
@echo off
for /f "delims=" %%i in ("%cd%") do (
echo %%i
dir c:\
dir x:\
) >nul 2>nul
Last edited by scriptor on 2007-10-11 at 12:36 AM ]