
[英]Windows batch file - sorting files by modified and/or creation date into folders
[英]Get file's modified date with condition - Batch Windows
我在Windows
有一个file.txt
,我想用if statement
检查文件的修改日期是否等于某个日期。
它将检入batch file
。
这是获取日期的想法:
for %a in (file.txt) do set FileDate=%~ta
但是我需要一个条件,如果条件为真,它将执行sqlcmd命令。
你可以尝试一下:
set date_today=%date:~0,2%/%date:~3,2%/%date:~6,4%
for %%x in ("your_file.txt") do set date_of_file=%%~tx
IF %date_of_file:~0, 10% == %date_today% goto same
goto notsame
:same
your sqlcmd command
:notsame
another thing
当然,您可以将%date_today%修改为所需的日期。
您对我的期望并不十分明确。
您的file.sql是否包含只返回一行和一个日期的查询?
因此,我认为您应该执行file.sql(带有一些sqlcmd),然后获取查询的输出,最后与批处理文件中的IF语句进行比较。 我当然可以为您提供帮助,但是我不确定您想要什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.