China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 21:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to add >nul 2>nul at the end of each line in a batch script View 2,484 Replies 17
Original Poster Posted 2008-09-09 19:16 ·  中国 广东 梅州 电信
中级用户
★★
Credits 262
Posts 129
Joined 2007-07-11 06:50
19-year member
UID 93679
Gender Male
Status Offline
It's a bit too inconvenient, but if you don't want it to display, you can only manually add " >nul 2>nul" to each line. Remember: " >nul 2>nul" (excluding the double quotes, but there's a space in front to avoid conflicts with the command. How to drag a certain cmd or bat to this batch processing icon to automatically add " >nul 2>nul" to the end of each line. Remember, it's to be achieved by dragging to the icon, not by running the batch processing first and entering the path. Create another file after the command to avoid overwriting the source file.
Floor 2 Posted 2008-09-09 19:40 ·  中国 福建 漳州 联通
中级用户
★★
Credits 228
Posts 125
Joined 2008-08-25 19:17
17-year member
UID 124135
Gender Male
Status Offline
I don't know what you don't want him to display?
@echo off
You can not display the running commands.
Only some execution results need >nul 2>nul
Not all need >nul2 >nul
Floor 3 Posted 2008-09-09 19:43 ·  中国 福建 漳州 联通
中级用户
★★
Credits 228
Posts 125
Joined 2008-08-25 19:17
17-year member
UID 124135
Gender Male
Status Offline
Also. It's impossible to achieve the result by throwing the file onto the batch processing icon. It seems it can't be done.
But you can open the batch processing and then drag the file you want to process into the batch processing. That can be done. Hehe
Floor 4 Posted 2008-09-09 19:49 ·  中国 北京 海淀区 联通
银牌会员
★★★
Credits 2,098
Posts 566
Joined 2007-09-11 07:27
18-year member
UID 97070
Gender Male
Status Offline
@for /f "usebackq eol=" %%a in ("%~f1") do @echo %%a ^>nul 2^>nul>> "%~dp1_%~nx1"
Floor 5 Posted 2008-09-09 22:32 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 195
Posts 93
Joined 2006-10-28 08:20
19-year member
UID 68626
Gender Male
Status Offline
Use an editor with regular expressions, such as EP. Replace - check the regular expression - $ followed by a space >nul 2>nul. Done
Floor 6 Posted 2008-09-10 19:41 ·  中国 广东 梅州 电信
中级用户
★★
Credits 262
Posts 129
Joined 2007-07-11 06:50
19-year member
UID 93679
Gender Male
Status Offline
2nd floor, that's a wrong statement!
Using the reg command will prompt that the operation is successful, and then it will be displayed.

The 4th floor doesn't work.
Floor 7 Posted 2008-09-10 20:06 ·  中国 福建 漳州 联通
中级用户
★★
Credits 228
Posts 125
Joined 2008-08-25 19:17
17-year member
UID 124135
Gender Male
Status Offline
I'm sorry, I didn't even know this could be done..
But the method on the 4th floor really works. Why do you say it doesn't work?
Did you make a mistake there? Otherwise, it passed my test here.
Floor 8 Posted 2008-09-10 20:33 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Q: Why doesn't it work?
A: Find an old military doctor's phone on the utility pole. He specializes in and cures this. If the treatment cycle is long, it is recommended to list your test environment, test cases, and error messages for everyone to help you solve the problem.
Floor 9 Posted 2008-09-10 22:38 ·  中国 江苏 苏州 电信
初级用户
Credits 24
Posts 12
Joined 2008-09-08 17:17
17-year member
UID 125134
Gender Male
Status Offline
Haven't heard of it being possible like this, it's too amazing
Floor 10 Posted 2008-09-11 19:11 ·  中国 广东 梅州 电信
中级用户
★★
Credits 262
Posts 129
Joined 2007-07-11 06:50
19-year member
UID 93679
Gender Male
Status Offline
You write taskkill /im explorer.exe /f in the BAT, then save it and drag it in to see it~
Floor 11 Posted 2008-09-11 20:23 ·  中国 福建 漳州 联通
中级用户
★★
Credits 228
Posts 125
Joined 2008-08-25 19:17
17-year member
UID 124135
Gender Male
Status Offline
Please provide the specific code that needs to be translated. Since you haven't provided the code content yet, please paste the relevant code here.
Floor 12 Posted 2008-09-11 22:45 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
batch.cmd >nul 2>nul
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 13 Posted 2008-09-12 17:03 ·  中国 广东 梅州 电信
中级用户
★★
Credits 262
Posts 129
Joined 2007-07-11 06:50
19-year member
UID 93679
Gender Male
Status Offline
The original Chinese text is about code conversion. The first code is `taskkill /im explorer.exe /f` and the converted one is `taskkill >nul 2>nul`. Since the task is just to present the conversion result as required, the translated result is:


taskkill >nul 2>nul
Floor 14 Posted 2008-09-12 17:07 ·  中国 北京 海淀区 联通
银牌会员
★★★
Credits 2,098
Posts 566
Joined 2007-09-11 07:27
18-year member
UID 97070
Gender Male
Status Offline
Originally posted by kidzgy at 2008-9-12 05:03 PM:
Source file code:

taskkill /im explorer.exe /f


After conversion:

taskkill >nul 2>nul


Change to:
@for /f "usebackq eol= delims=" %%a in ("%~f1") do @echo %%a ^>nul 2^>nul>> "%~dp1_%~nx1"


[ Last edited by s11ss on 2008-9-12 at 05:13 PM ]
Floor 15 Posted 2008-09-12 19:27 ·  中国 广东 梅州 电信
中级用户
★★
Credits 262
Posts 129
Joined 2007-07-11 06:50
19-year member
UID 93679
Gender Male
Status Offline
Well, it works, thank you~!
Forum Jump: