Board logo

标题: DOS 下如何对指定时间段的文件操作. [打印本页]

作者: yzzhuu     时间: 2009-6-20 23:12    标题: DOS 下如何对指定时间段的文件操作.

想要把某个目录下(包含子目录)所有日期的修改时间为大于早七点三十分小于晚八点十五分的所有文件全部找出来并拷贝走或者全部删除也行,试了xcopy命令但只是支持天不支持小时分钟秒.
作者: DOSforever     时间: 2009-6-28 10:07
介绍一个参数,这个参数差不多可以在所有以文件为操作对象的 4DOS 命令中使用

  Quote:

4DOS Help Topic:  Time Ranges


A time range specifies a file modification time without reference to the
date.  For example, to select files modified between noon and 2:00 pm on any
date, use /[t12:00p,2:00p].  The times in a time range can either be in
12-hour format, with a trailing "a" for AM or "p" for PM, or in 24-hour
format.

If you omit the second argument in a time range, you will select files that
were modified between the first time and the current time, on any date.  You
can also use offsets, beginning with a plus sign [+] or a minus sign [-] for
either or both of the arguments in a time range.  The offset values are
interpreted as minutes.  Some examples:

     Specification       Selects Files

     /[t12:00p,+120]     modified between noon and 2:00 PM on any date
     /[t-120,+120]       modified between two hours ago and the current
                         time on any date
     /[t0:00,11:59]      modified in the morning on any date

The standard FAT file system maintains a single time for each file,
reflecting the last time the file was written.  This is the time 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, time ranges work with the last write time stamp.  You
can use the "last access" (a) or "created" (c) time stamp in a time range
with the syntax:

     /[ta...]  or  /[tc...]

如按照你具体的需求:修改时间大于七点三十分小于晚八点十五分
可以这样

copy /s /[t7:30,20:15] ... ...

del /s /[t7:30,20:15] ...