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-11 03:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] Batch Processing to Filter and Keep Specified Content in Text View 2,416 Replies 18
Floor 16 Posted 2008-04-02 15:45 ·  中国 北京 华为云
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Most friends here learn or come into contact with scripts to bring efficiency to life or work. This is also the purpose of most script developers. But if there is a better, quicker and more efficient method not used, and instead one settles for a second-best option, isn't that somewhat putting the cart before the horse?
Floor 17 Posted 2008-04-02 16:29 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
I learn it because it's fun and concise. Unlike other high-level languages that have classes and stuff, it's annoying. The compiled file for a simple task is nearly 1M. Also, it's very convenient, just need to use Notepad.
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 18 Posted 2008-04-02 20:57 ·  中国 辽宁 沈阳 联通
中级用户
★★
Credits 234
Posts 119
Joined 2007-04-22 11:09
19-year member
UID 86077
Gender Male
Status Offline
@echo off
for /f "delims=" %%i in ('findstr /i "\.asp" a.txt') do (
set "var=%%i"
setlocal enabledelayedexpansion
set var=!var:"=!
set var=!var:#=!
set var=!var:"=!
set var=!var:^>=!
set var=!var:^<=!
set var=!var:/==!
set var=!var:.asp=#!
call :loop
endlocal
)
cd.>asp.txt
for /f "eol= delims=" %%i in (b.txt) do (
findstr /xc:"%%i" asp.txt >nul 2>nul||echo %%i>>asp.txt
)
del b.txt
start asp.txt
exit
:loop
for /f "delims=#" %%a in ("!var!") do call :lis "%%a"
goto :eof
:lis
for /f "tokens=1* delims==" %%a in ("%~1") do (
if not "%%b"=="" (call :lis "%%b") else >>b.txt echo %%a.asp
)
goto :eof

Thanks to the generous help from all brothers, the Internet is wonderful because of you.
I have added code to eliminate duplicate lines above, which realizes the function of eliminating duplicate lines. I don't know what method can be used to achieve the result of outputting a.asp|b.asp|c.asp...
Floor 19 Posted 2009-01-02 01:04 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
@echo off&setlocal enabledelayedexpansion
for /f "tokens=* delims=:" %%a in ('findstr /n ".asp" a.txt') do (

set var=%%a
set var=!var:/= !
set var=!var:"= !
set var=!var:?= !
set var=!var::= !
set var=!var:^>= !
set var=!var:^<= !

for %%i in (!var!) do (

set aaa=%%i
set aaa=!aaa:~-4!
if !aaa!==.asp set bbb=!bbb!^|%%i

)
)

set bbb=!bbb:~1!
echo =================================================================
echo !bbb!
echo =================================================================
pause
Forum Jump: