Board logo

标题: 在Dos命令行中如何判断当前(或者给定日期)是星期几? [打印本页]

作者: hnhhcj     时间: 2006-11-29 23:52    标题: 在Dos命令行中如何判断当前(或者给定日期)是星期几?

如题。
作者: zh159     时间: 2006-11-30 02:05
echo %date:~-3%
(XP SP1)
作者: redtek     时间: 2006-11-30 07:44
(显示)当前日期是星期几,输出英文:因MS-DOS是英文版:)


(版本: MS-DOS  6.22)
(Windows CMD Shell无效)
echo exit|command /k prompt $d$h$h$h$h$h$h$h$h$h$h$_|find /v "exit"
输出:
Tue

作者: 0451lym     时间: 2006-11-30 11:29
GetInfo.COM [/T] [/C] [/D:+|-days] [/G:n,filename] [/Cmp:x,y]      ver 1.2

/T   Get current date and time.
     And It will modify follow environment variable.
     year,mon,day,wday
     hour,min,sec

/C   Get the first CDRom.
     And It will modify follow environment variable.
     CDRom

/D   It will modify follow environment variable.
     year,mon,day,wday

/G:n,filename
     Get the String from the text file.
     The String must be short then 2048 Byte!
     It will modify follow environment variable.
     GetString,TheString

/Cmp:x,y
     x=y  return 0
     x<y  return 1
     x>y  return 2


=====================================================
版本 1.2        更新日期:2005-10-16

功能介绍:

[/Cmp:x,y]
        比较两个数,并返回一个数值
        x=y  return 0
        x<y  return 1
        x>y  return 2

例子:


比较12和13,并显示结果
@echo off
getinfo /cmp:12,13
if errorlevel 2 goto big
if errorlevel 1 goto small
if errorlevel 0 goto equ
goto end

:big
echo x bigger than y
goto end

:small
echo x smaller than y
goto end

:equ
echo x = y

:end



判断今天的日期是否跟设定的日期相同
@echo off
getinfo /t
set today=%Year%%Mon%%Day%
getinfo /cmp:%today%,20051016
if errorlevel 2 goto big
if errorlevel 1 goto small
if errorlevel 0 goto equ
goto end

:big
echo 已过了设定的日期
goto end

:small
echo 还没有到设定的日期
goto end

:equ
echo 今天就是设定的日期

:end




=====================================================
版本 1.1        更新日期:2005-06-24

功能介绍:


[/T]
取得当前系统的日期和时间,并设置下列环境变量。
year:年     mon:月     day:日      wday:星期几(星期天是7)
hour:时     min:分     sec:秒


[/C]
取得第一个光驱的盘符,并设置环境变量CDRom。
如果有光驱,设置为光驱的盘符。
如果没有光驱,设置为NoCDRom


[/D:+|-days]
将当前系统的日期与所指定的days进行计算,得到另一个日期,并设置下列环境变量。
year:年     mon:月     day:日      wday:星期几(星期天是7)

例子:
GetInfo.com /d:-1        得到昨天的日期
GetInfo.com /d:+1        得到明天的日期


[/G:n,filename]
从指定的文本文件里面,取得第n行的内容,将内容保存在TheString中,
如果该行的字符串长度大于2048个字符,就只取2048个字符。
成功时GetString=TRUE,否则,GetString=FALSE

例子:
GetInfo.com /g:5,D:\A.TXT        得到D:\A.TXT中第5行的内容



另外,该程序现在编译成.com文件,它的体积比原先的GetInfo.exe
小了一半。