如何在Windows/DOS命令中获取文件的最后修改日期 [英] How to get a file's last modified date on windows/dos command
问题描述
我希望从
C:\Program Files (x86)\FolderTransfer4\WRTEUHH.dll
我使用了脚本
for %a in (WRTEUHH.dll) do set FileDate=%~ta
在此处发布的内容:如何获取Windows命令行上文件的最后修改日期?
此脚本有效.但是,仅当该DLL位于命令提示符运行所在的文件夹中时,此方法才有效.如果可能的话,我想从该程序文件文件夹中获取它,并从那里直接获取日期.
This script works. However, this only works if that DLL is in the same folder where command prompt ran from. I would like to get it from that program files folder and the date from there directly if possible.
推荐答案
以下是一些适合您的示例:
Here are a few examples for you:
最后写入的日期和时间- (cmd.exe) (使用提供的示例进行变量参考扩展)
Last Written Date and Time - (cmd.exe) using provided example with for variable reference expansion
FOR %A IN ("%ProgramFiles(x86)%\FolderTransfer4\WRTEUHH.dll") DO @ECHO=%~tA
最后写入的日期和时间- (cmd.exe) ,在for循环中使用where命令,(不适用于使用AM/PM的本地时间输出)符号)
Last Written Date and Time - (cmd.exe) using where command in for loop, (does not cater for local time outputs using AM/PM notation)
FOR /F "TOKENS=2-3" %A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @ECHO=%A %B
仅最后写入日期- (cmd.exe) (使用for循环中的where命令)
Last Written Date only - (cmd.exe) using where command in for loop
FOR /F "TOKENS=2" %A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @ECHO=%A
最后写入的日期和时间- (批处理文件) ,使用提供的示例进行变量引用扩展
Last Written Date and Time - (batch file) using provided example with for variable reference expansion
@FOR %%A IN ("%ProgramFiles(x86)%\FolderTransfer4\WRTEUHH.dll") DO @(ECHO=%%~tA&PAUSE)
最后写入的日期和时间- (批处理文件) ,在for循环中使用where命令,(不适应使用AM/PM表示法的本地时间输出)
Last Written Date and Time - (batch file) using where command in for loop, (does not cater for local time outputs using AM/PM notation)
@FOR /F "TOKENS=2-3" %%A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @(ECHO=%%A %%B&PAUSE)
仅最后写入日期- (批处理文件) ,使用for循环中的where命令
Last Written Date only - (batch file) using where command in for loop
@FOR /F "TOKENS=2" %%A IN ('WHERE /T "%ProgramFiles(x86)%\FolderTransfer4:WRTEUHH.dll"') DO @(ECHO=%%A&@PAUSE)
这篇关于如何在Windows/DOS命令中获取文件的最后修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!