简体   繁体   中英

How to get last modified date for multiple files in a directory using a Batch file

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?

Does this help?

Yes, you can do this using the for command with the /r switch, eg: for /r %%f in (*) do echo %%f

from this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM