【发布时间】:2014-08-19 23:13:39
【问题描述】:
我需要做一个批处理文件,按日期间隔对所有文件进行排序,例如:
@echo off
echo Input the date(dd/mm/yyyy):
set /p compDate=
::After that I will compare from the actual day (%date%), example:
set interval = %compDate% - %date%... *Something like that*
::After that I need to list all files from a specific directory, example:
echo Input the directory:
set /p directory=
SET Exit= %UserProfile%\Desktop\test.txt
::After that I might need dir /tc to get the creation date, example:
pushd "%directory%"
dir /s /tc /a-d > %Exit%
::After that I don't know how to get only the lines which are in date interval, example:
今天是 2014 年 8 月 19 日,但我想搜索从 2014 年 7 月 10 日创建的所有文件。 所以我必须复制所有日期为 10/07/2014、11/07/2014、12/07/2014 等的行,直到今天创建的文件停止。
我尝试使用findstr,但我无法设置日期间隔,只能在创建的 .txt 中搜索特定日期。
有人知道怎么做吗?
【问题讨论】:
-
forfiles命令用于执行此操作。尝试使用它。XCopy也可以做到(它可以列出要复制的文件而不复制它们)。两者都允许按日期选择。输入xcopy /?和forfiles /?。 -
批处理中没有日期/时间计算程序或函数。
-
forfiles /d +26/2/2014 /p c:\windows /m *.txt /c "cmd /c echo @fpath @fdate
标签: date batch-file batch-processing intervals