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-06 08:33
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to query and output a section of data between 2 dates View 1,586 Replies 20
Floor 16 Posted 2007-10-31 12:26 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
sed is a third-party command-line tool

You need to download it, the forum seems to have it, OP can search for it yourself
Floor 17 Posted 2007-10-31 12:55 ·  中国 河南 郑州 联通
初级用户
Credits 30
Posts 13
Joined 2007-10-26 10:25
18-year member
UID 100817
Gender Male
Status Offline
Originally posted by abcd at 2007-10-31 12:26 PM:
sed is a third-party command-line tool

You need to download it; the forum seems to have it, OP can search for it yourself

Got it, thanks for the reminder

I want to know whether it can be done without relying on third-party tools
Floor 18 Posted 2007-10-31 13:30 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Of course it can be done, but the efficiency is obviously not as high as sed

Sometimes don't be so set on using only the commands built into windows

Isn't text processing all about efficiency?

If it's purely for research, then you can write it, but if it's simply to improve the speed of text processing

you might as well consider third-party tools
Floor 19 Posted 2007-10-31 14:25 ·  中国 河南 郑州 联通
初级用户
Credits 30
Posts 13
Joined 2007-10-26 10:25
18-year member
UID 100817
Gender Male
Status Offline
<!Originally posted by abcd at 2007-10-31 01:30 PM:
Of course it can be done, but the efficiency is obviously not as high as sed

Sometimes don't be so set on using only the commands built into windows

Isn't text processing all about efficiency?

If it's purely for research, ...

1 is for processing documents, 2 is for learning. Learn the logical thinking of the experts a bit, and improve my own ability :P
Hope someone can help write pure ms-dos code :)]>
Floor 20 Posted 2007-10-31 14:58 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
@echo off

for /f "skip=1 tokens=1-6" %%i in (t.txt) do (
set dt=%%m
setlocal enabledelayedexpansion
set dt=!dt:年= !
set dt=!dt:月= !
set dt=!dt:日=!
call :ys "!dt!"
if "!string:~1!" gtr "2007-04-20" if "!string:~1!" lss "2007-10-20" echo %%i %%j %%k %%l %%m %%n
endlocal
)
pause
goto :eof

:ys
set string=
for %%a in (%~1) do (
if %%a leq 9 (set str=0%%a) else (set str=%%a)
set string=!string!-!str!
)


Try this??
Floor 21 Posted 2007-10-31 17:20 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
This will do it
::

@echo off
setlocal EnableDelayedExpansion
echo Please enter the start date, for example:2007 3 29
set /p d=
call :lis "%d%" d
echo Please enter the end date, for example:2007 10 9
set /p h=
call :lis "%h%" h
set /p var=<a.txt
cls
echo %var%
for /f "delims=" %%i in (a.txt) do (
for /f "tokens=5 delims= " %%a in ("%%i") do (
if not "%%a"=="" (
set num=%%a
set num=!num:年=-!
set num=!num:月=-!
set num=!num:日=!
call :lis "!num!" num
if !num! geq !d! if !num! leq !h! echo %%i
)))
pause
exit
:lis
for /f "tokens=1-3 delims=- " %%a in ("%~1") do (
set m=0%%b
set yy=0%%c
set %2=%%a-!m:~-2!-!yy:~-2!
)
goto :eof
致精致简!
Forum Jump: