![]() |
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-09-30 10:25 |
47,813 topics / 349,918 posts / today 0 new / 48,279 members |
| DOS批处理 & 脚本技术(批处理室) » [Closed] Batch Processing to Filter and Keep Specified Content in Text |
| Printable Version 2,731 / 18 |
| Floor16 abcd | Posted 2008-04-02 15:45 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
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?
|
|
| Floor17 plp626 | Posted 2008-04-02 16:29 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
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.
|
|
| Floor18 w1314ich | Posted 2008-04-02 20:57 |
| 中级用户 Posts 119 Credits 234 | |
|
@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... |
|
| Floor19 netbenton | Posted 2009-01-02 01:04 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
@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 |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |