中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » 如何在DOS或WIN的命令提示符里搜索指定日期的文件?
作者:
标题: 如何在DOS或WIN的命令提示符里搜索指定日期的文件? 上一主题 | 下一主题
poplarshine
初级用户





积分 24
发帖 8
注册 2008-8-15
状态 离线
『楼 主』:  如何在DOS或WIN的命令提示符里搜索指定日期的文件?

如何在DOS或WIN的命令提示符里搜索指定日期的文件?

2008-10-26 17:57
查看资料  发短消息 网志   编辑帖子  回复  引用回复
newsuper
新手上路

坚持学习



积分 18
发帖 15
注册 2008-10-18
状态 离线
『第 2 楼』:  

用for循环和dir应该可以吧。
cd.>x:\list.txt & for /f "tokens=1-3*" %i in ('dir /s x:') do if %i==date echo %l >>x:\list.txt
式中你要查询的盘替换掉x:,用查询日期(例如2008-10-26)替换掉date,首先在你要查询的盘的根目录下生成一个list.txt文件。然后for循环显示你要查询的文件清单。
   对了,这个是在命令行里直接写的,要放到批处理里的话,要把所有的%变成%%.
  自己随便写的,不知道对不对,请高手指教。

[ Last edited by newsuper on 2008-10-26 at 19:18 ]

2008-10-26 19:13
查看资料  发短消息 网志   编辑帖子  回复  引用回复
HAT
版主





积分 9023
发帖 5017
注册 2007-5-31
状态 离线
『第 3 楼』:  

如果不会写批处理,可以用GNU for win32的find.exe



2008-10-27 23:11
查看资料  发短消息 网志   编辑帖子  回复  引用回复
DOSforever
金牌会员





积分 4639
发帖 2239
注册 2005-1-30
状态 离线
『第 4 楼』:  

4DOS 有个日期范围选择功能

  Quote:
4DOS Help Topic:  Date Ranges


Date ranges select files that were created or last modified at any time
between the two dates.  For example, /[d12-1-99,12-5-99] selects files that
were last modified between December 1, 1999, and December 5, 1999.

You can use hyphens, slashes, or periods to separate the month, day, and
year.  4DOS generally accepts dates between January 1, 1980 and December 31,
2099.  The year can be entered as a 2-digit or 4-digit value.  Two-digit
years between 80 and 99 are interpreted as 1980 - 1999; values between 00
and 79 are interpreted as 2000 - 2079.  References to years beyond 2079 must
be entered with 4 digits.  For example, /[d12-31-99,1-1-00] is equivalent to
/[d12-31-1999,1-1-2000], and selects files modified on December 31, 1999 or
January 1, 2000.

If an argument begins with a four digit year greater than 1900, it's assumed
to be a date in the ISO 8601 international format (yyyy-mm-dd).  If the date
contains the letter "W", it is assumed to be in the ISO 8601 week date
format yyyy-Www-d, where yyyy = year, ww = week, d = week day.  If the date
is entered as two numbers in the format yyyy-ddd, it is assumed to be in the
ISO 8601 ordinal date format, where yyyy = year, ddd = day of the year.

The time for the starting date defaults to 00:00:00 and the time for the
ending date defaults to 23:59:59.  You can alter these defaults, if you
wish, by including a start and stop time inside the date range.  The time is
separated from the date with an at sign [@].  For example, the range
/[d7-1-00@8:00a,7-3-00@6:00p] selects files that were modified at any time
between 8:00 am on July 1, 2000 and 6:00 pm on July 3, 2000.  If you prefer,
you can specify the times in 24-hour format (e.g., @18:00 for the end time
in the previous example).

If you omit the second argument in a date range, 4DOS substitutes the
current date and time.  For example, /[d10-1-99] selects files dated between
October 1, 1999 and today.

You can use an offset value for either the beginning or ending date, or
both.  An offset begins with a plus sign [+] or a minus sign [-] followed by
an integer.  If you use an offset for the second value, it is calculated
relative to the first.  If you use an offset for the first (or only) value,
the current date is used as the basis for calculation.  For example:

     Specification       Selects Files

     /[d10-27-99,+3]     modified between 10-27-99 and 10-30-99
     /[d10-27-99,-3]     modified between 10-24-99 and 10-27-99
     /[d-0]              modified today (from today minus zero days, to
                         today)
     /[d-1]              modified yesterday or today (from today minus one
                         day, to today)
     /[d-1,+0]           modified yesterday (from today minus one day, to
                         zero days after that)

As a shorthand way of specifying files modified today, you can also use
/[d]; this has the same effect as the /[d-0] example shown above.

To select files last modified n days ago or earlier, use /[dn,1/1/80].  For
example, to get a directory of all files last modified 3 days or more before
today (i.e., those files not modified within the last 3 days), you could use
this command:

     c:\> dir /[d-3,1/1/80]

This reversed date range (with the later date given first) will be handled
correctly by 4DOS.  It takes advantage of the facts that an offset in the
start date is relative to today, and that the base or "zero" point for PC
file dates is January 1, 1980.

Note:  If you do not specify a time in a reversed date range, the default
times will be applied before the first and second dates are swapped to
become the ending and starting dates respectively.  If you want to include
the entire first and last days of a reversed date range, simply add a
specific @00:00:00 to your intended start date and a @23:59:59 to your
intended end date.

You cannot use offsets in the time portion of a date range (the part after
an @ sign), but you can combine a time with a date offset.  For example,
/[d12-8-99@12:00,+2@12:00] selects files that were last modified between
noon on December 8 and noon on December 10, 1999.  Similarly,
/[d-2@15:00,+1] selects files last modified between 3:00 pm the day before
yesterday and the end of the day one day after that, i.e., yesterday.  The
second time defaults to the end of the day because no time is given.

The standard FAT file system maintains a single date for each file,
reflecting the last time the file was written.  This is the date used by
4DOS on a FAT drive with no LFN support (e.g. under MS-DOS 6.22, PC DOS 7.0
or 2000, DR-DOS 7.03 without LONGNAME loaded, or OS/2).

Drives which support long filenames (e.g. under Windows 95/98/ME, or under
plain DOS with a suitable LFN driver loaded) maintain 3 sets of dates and
times for each file: creation, last access, and last write (for last access
only the date is recorded; the last access time is always returned as
00:00).  By default, date ranges work with the last write time stamp.  You
can use the "last access" (a) or "created" (c) date/time stamp in a date
range with the syntax:

     /[da...]  or  /[dc...]

For example, to select files that were last accessed yesterday or today:

     /[da-1]


Date ranges select files that were created or last modified at any time
between the two dates.  For example, /[d12-1-99,12-5-99] selects files that
were last modified between December 1, 1999, and December 5, 1999.

You can use hyphens, slashes, or periods to separate the month, day, and
year.  4DOS generally accepts dates between January 1, 1980 and December 31,
2099.  The year can be entered as a 2-digit or 4-digit value.  Two-digit
years between 80 and 99 are interpreted as 1980 - 1999; values between 00
and 79 are interpreted as 2000 - 2079.  References to years beyond 2079 must
be entered with 4 digits.  For example, /[d12-31-99,1-1-00] is equivalent to
/[d12-31-1999,1-1-2000], and selects files modified on December 31, 1999 or
January 1, 2000.

If an argument begins with a four digit year greater than 1900, it's assumed
to be a date in the ISO 8601 international format (yyyy-mm-dd).  If the date
contains the letter "W", it is assumed to be in the ISO 8601 week date
format yyyy-Www-d, where yyyy = year, ww = week, d = week day.  If the date
is entered as two numbers in the format yyyy-ddd, it is assumed to be in the
ISO 8601 ordinal date format, where yyyy = year, ddd = day of the year.

The time for the starting date defaults to 00:00:00 and the time for the
ending date defaults to 23:59:59.  You can alter these defaults, if you
wish, by including a start and stop time inside the date range.  The time is
separated from the date with an at sign [@].  For example, the range
/[d7-1-00@8:00a,7-3-00@6:00p] selects files that were modified at any time
between 8:00 am on July 1, 2000 and 6:00 pm on July 3, 2000.  If you prefer,
you can specify the times in 24-hour format (e.g., @18:00 for the end time
in the previous example).

If you omit the second argument in a date range, 4DOS substitutes the
current date and time.  For example, /[d10-1-99] selects files dated between
October 1, 1999 and today.

You can use an offset value for either the beginning or ending date, or
both.  An offset begins with a plus sign [+] or a minus sign [-] followed by
an integer.  If you use an offset for the second value, it is calculated
relative to the first.  If you use an offset for the first (or only) value,
the current date is used as the basis for calculation.  For example:

     Specification       Selects Files

     /[d10-27-99,+3]     modified between 10-27-99 and 10-30-99
     /[d10-27-99,-3]     modified between 10-24-99 and 10-27-99
     /[d-0]              modified today (from today minus zero days, to
                         today)
     /[d-1]              modified yesterday or today (from today minus one
                         day, to today)
     /[d-1,+0]           modified yesterday (from today minus one day, to
                         zero days after that)

As a shorthand way of specifying files modified today, you can also use
/[d]; this has the same effect as the /[d-0] example shown above.

To select files last modified n days ago or earlier, use /[dn,1/1/80].  For
example, to get a directory of all files last modified 3 days or more before
today (i.e., those files not modified within the last 3 days), you could use
this command:

     c:\> dir /[d-3,1/1/80]

This reversed date range (with the later date given first) will be handled
correctly by 4DOS.  It takes advantage of the facts that an offset in the
start date is relative to today, and that the base or "zero" point for PC
file dates is January 1, 1980.

Note:  If you do not specify a time in a reversed date range, the default
times will be applied before the first and second dates are swapped to
become the ending and starting dates respectively.  If you want to include
the entire first and last days of a reversed date range, simply add a
specific @00:00:00 to your intended start date and a @23:59:59 to your
intended end date.

You cannot use offsets in the time portion of a date range (the part after
an @ sign), but you can combine a time with a date offset.  For example,
/[d12-8-99@12:00,+2@12:00] selects files that were last modified between
noon on December 8 and noon on December 10, 1999.  Similarly,
/[d-2@15:00,+1] selects files last modified between 3:00 pm the day before
yesterday and the end of the day one day after that, i.e., yesterday.  The
second time defaults to the end of the day because no time is given.

The standard FAT file system maintains a single date for each file,
reflecting the last time the file was written.  This is the date used by
4DOS on a FAT drive with no LFN support (e.g. under MS-DOS 6.22, PC DOS 7.0
or 2000, DR-DOS 7.03 without LONGNAME loaded, or OS/2).

Drives which support long filenames (e.g. under Windows 95/98/ME, or under
plain DOS with a suitable LFN driver loaded) maintain 3 sets of dates and
times for each file: creation, last access, and last write (for last access
only the date is recorded; the last access time is always returned as
00:00).  By default, date ranges work with the last write time stamp.  You
can use the "last access" (a) or "created" (c) date/time stamp in a date
range with the syntax:

     /[da...]  or  /[dc...]

Windows 下可以用 4NT 或 Take Command



DOS倒下了,但永远不死
DOS NEVER DIES !

投票调查:
http://www.cn-dos.net/forum/viewthread.php?tid=46187

本人尚未解决的疑难问题:
http://www.cn-dos.net/forum/viewthread.php?tid=15135
http://www.cn-dos.net/forum/viewthread.php?tid=47663
http://www.cn-dos.net/forum/viewthread.php?tid=48747
2008-10-29 16:02
查看资料  发短消息 网志   编辑帖子  回复  引用回复
clian76
中级用户





积分 363
发帖 162
注册 2007-4-22
状态 离线
『第 5 楼』:  

用 FOR 和 %%~t0 可以

2008-11-3 00:38
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: