如何使用批处理文件获取目录中多个文件的最后修改日期
例如,例如标题,想在目录/路径(c:\ users)中获取这些扩展文件(.exe,.txt)的最后一个修改日期。我应该怎么做?
我是新手,在这里找到了一些类似的主题,但发现其中大部分仅适用于一个文件。
以下是我的示例代码,适用于任何人可以提供帮助的单个文件
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "date=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
set host=%COMPUTERNAME%
ECHO DREFPFS.txt >> C:\Users\Desktop\temp\Version\%host%_CopyFiles_%date%.txt
@FOR %%A IN ("%C:\Users\Desktop\temp\DREFPFS.txt") DO @(ECHO=%%~tA) >> C:\Users\Desktop\temp\Version\%host%_CopyFiles_%date%.txt
?
As title, for example would like to get the last modified date for these extension file (.exe, .txt) in a directory/path (C:\Users). How should i do it?
I am a novice on this and found some similar topics here but found most of it only work for a single file.
Below are my example code that work for a single file
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "date=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
set host=%COMPUTERNAME%
ECHO DREFPFS.txt >> C:\Users\Desktop\temp\Version\%host%_CopyFiles_%date%.txt
@FOR %%A IN ("%C:\Users\Desktop\temp\DREFPFS.txt") DO @(ECHO=%%~tA) >> C:\Users\Desktop\temp\Version\%host%_CopyFiles_%date%.txt
Anyone can help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有帮助吗?
;子树在windows-batch-file中”>这个问题
Does this help?
from this question