![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 22:26 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » New space deletion problem?? |
| Printable Version 2,708 / 40 |
| Floor1 amio | Posted 2008-05-29 20:00 |
| 中级用户 Posts 93 Credits 206 | |
|
----------------------
aaa bbb [abcd] aaa bbb cc dd --------------------- |
|
| Floor2 bat-zw | Posted 2008-05-29 20:17 |
| 金牌会员 Posts 1,276 Credits 3,105 | |
|
```
@echo off&setlocal enabledelayedexpansion for /f "delims=" %%i in (1.txt) do ( set str=%%i if "!str!" equ "" ( echo.&echo !str! ) else ( echo !str! ) ) pause>nul ``` |
|
| Floor3 amio | Posted 2008-05-29 20:26 |
| 中级用户 Posts 93 Credits 206 | |
|
Can the "" be replaced with something universal? Because there are also , , etc. How to obtain "
|
|
| Floor4 WANKOILZ | Posted 2008-05-29 20:27 |
| 初级用户 Posts 89 Credits 198 From 重庆 | |
|
I found a more concise one:
|
|
| Floor5 26933062 | Posted 2008-05-29 20:30 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
```
@echo off for /f "delims=" %%a in (a.txt) do ( if "%%a"=="" echo. echo %%a ) pause ``` |
|
| Floor6 26933062 | Posted 2008-05-29 20:32 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
Oh, after posting, I found out I'm on the 5th floor. I thought I was on the 3rd floor? It's exactly the same as the 4th floor. Haha...
|
|
| Floor7 WANKOILZ | Posted 2008-05-29 20:41 |
| 初级用户 Posts 89 Credits 198 From 重庆 | |
|
I'm still missing four quotation marks, heh heh........
|
|
| Floor8 amio | Posted 2008-05-29 20:47 |
| 中级用户 Posts 93 Credits 206 | |
|
[abcd] This is not just one, there are also [efgh], [ijk] and so on. If there are dozens of []s, it's too cumbersome to add them one by one.
|
|
| Floor9 WANKOILZ | Posted 2008-05-29 20:51 |
| 初级用户 Posts 89 Credits 198 From 重庆 | |
|
The situation mentioned by the person upstairs still needs to be analyzed on a case-by-case basis.
|
|
| Floor10 amio | Posted 2008-05-29 21:16 |
| 中级用户 Posts 93 Credits 206 | |
|
Can't we just make a judgment based on [? If there is [, leave a blank line above it
|
|
| Floor11 WANKOILZ | Posted 2008-05-29 21:20 |
| 初级用户 Posts 89 Credits 198 From 重庆 | |
|
If the first character of the line is '
@echo off&setlocal enabledelayedexpansion for /f "delims=" %%i in (1.txt) do ( set "str=%%i" if "!str:~0,1!"==" [ Last edited by WANKOILZ on 2008-5-29 at 09:22 PM ] |
|
| Floor12 zqz0012005 | Posted 2008-05-29 21:24 |
| 中级用户 Posts 135 Credits 297 | |
|
```@echo off
for /f "delims=" %%i in (1.txt) do ( echo %%i|findstr "^$">nul&&echo. echo %%i ) pause>nul |
|
| Floor13 26933062 | Posted 2008-05-29 21:35 |
| 银牌会员 Posts 879 Credits 2,268 | |
Originally posted by zqz0012005 at 2008-5-29 21:24: Hehe, the one upstairs really has an efficiency problem. |
|
| Floor14 amio | Posted 2008-05-29 21:39 |
| 中级用户 Posts 93 Credits 206 | |
Originally posted by 26933062 at 2008-5-29 09:35 PM: That one I tried doesn't work at all. |
|
| Floor15 amio | Posted 2008-05-29 21:49 |
| 中级用户 Posts 93 Credits 206 | |
|
There is another question. If there are spaces in front of each line, also delete them?
aaaaaaa bbbbbbbbb ----------------- aaaaaaa bbbbbbbbb |
|
| 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |