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-27 01:27
中国DOS联盟论坛 » 其它操作系统综合讨论区 » How to delete part of the content in Notepad? View 2,023 Replies 9
Original Poster Posted 2006-06-12 10:41 ·  中国 云南 昆明 电信
初级用户
★★
Credits 182
Posts 88
Joined 2005-11-29 05:52
20-year member
UID 46146
Status Offline
I have a notepad mybook.txt.
I want to use the DOS command to delete "bookID", "bookNUM" in this notepad. How should I write the command?
Floor 2 Posted 2006-06-12 23:45 ·  中国 浙江 杭州 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
It is estimated that it is difficult to achieve.
Floor 3 Posted 2006-06-13 10:26 ·  中国 云南 昆明 电信
初级用户
★★
Credits 182
Posts 88
Joined 2005-11-29 05:52
20-year member
UID 46146
Status Offline
Well, I think it's a bit difficult too, I'll just use JavaScript then. If any big brother knows it, that would be the best.
Floor 4 Posted 2006-06-14 13:25 ·  中国 福建 泉州 电信
高级用户
★★
论坛灌水专业户
Credits 613
Posts 266
Joined 2006-04-19 22:47
20-year member
UID 54113
From 河南省
Status Offline
Just re-edit it.
饮马恒河畔,剑指天山西,碎叶城揽月,库叶岛赏雪,黑海之滨垂钓,贝尔加湖面张弓;中南半岛访古,东京废墟祭祖!
Floor 5 Posted 2006-06-14 13:50 ·  中国 北京 鹏博士BGP
中级用户
★★
Credits 404
Posts 179
Joined 2006-03-30 14:44
20-year member
UID 53056
Status Offline
When it's a single line, you can use
for + findstr
Floor 6 Posted 2007-03-21 00:50 ·  中国 四川 德阳 电信
初级用户
Credits 96
Posts 45
Joined 2007-03-20 06:24
19-year member
UID 82322
Gender Male
Status Offline
I also want to know, how to find and add or delete strings or entire lines in Notepad?
Floor 7 Posted 2007-03-21 01:28 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
There is no content in mybook.txt, which is not good for writing...
我今后在论坛的目标就是做个超级坏人!!!
Floor 8 Posted 2007-03-21 01:55 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Floor 9 Posted 2007-03-21 02:07 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  If there is content of mybook.txt, maybe JavaScript and third-party tools can be avoided.
Floor 10 Posted 2007-03-29 10:57 ·  中国 四川 泸州 联通
高级用户
★★★
Credits 609
Posts 374
Joined 2006-08-02 22:38
20-year member
UID 59720
Status Offline
@echo off
:: Preserve blank lines and replace strings (Note: If replacing a batch program, the identifier ":" will be lost, and "=" cannot be replaced)
echo.
set /p waei= Drag the file whose characters you want to replace to this window:
echo.
set /p wasy= Enter the text to be replaced:
echo.
set /p sybm= Enter the replacement text:
echo.
echo The program is running, please wait... ...
set "waei=%waei:"=%"
for %%i in ("%waei%") do set waei=%%~fi
cd.>"%waei%_tmp.txt"
setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%waei%"') do (
set str=%%j
if not "!str!"=="" set "str=!str:%wasy%=%sybm%!"
>>"%waei%_tmp.txt" echo.!str!
)
copy "%waei%" "%waei%_bak.txt" >nul 2>nul
move "%waei%_tmp.txt" "%waei%"
@cls
@echo.
@echo Replacement completed
pause>nul
Forum Jump: