How to get file's last modified date on Windows command line?

前端 未结 8 1665
星月不相逢
星月不相逢 2020-12-01 04:16

I have been using the following command to get the file date. However, the fileDate variable has been returning blank value ever since we moved to a different s

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 04:39

    Useful reference to get file properties using a batch file, included is the last modified time:

    FOR %%? IN ("C:\somefile\path\file.txt") DO (
        ECHO File Name Only       : %%~n?
        ECHO File Extension       : %%~x?
        ECHO Name in 8.3 notation : %%~sn?
        ECHO File Attributes      : %%~a?
        ECHO Located on Drive     : %%~d?
        ECHO File Size            : %%~z?
        ECHO Last-Modified Date   : %%~t?
        ECHO Drive and Path       : %%~dp?
        ECHO Drive                : %%~d?
        ECHO Fully Qualified Path : %%~f?
        ECHO FQP in 8.3 notation  : %%~sf?
        ECHO Location in the PATH : %%~dp$PATH:?
    )
    

提交回复
热议问题