Batch File Get Last Modified Date whille looping thru subdirectories

56 Views Asked by At

I am looping through all subdirectories inside a directory, and wish to both save and echo the last modified date of each.

I cannot figure out the right type of for loop to do this. The following works to get me the subdirectory names, but I am unable to get their last modified date.

for /F "tokens=*" %%a in ('dir /b /a:d /o:n !some_path')... 

I have to do an extra forfiles loop to get the last modified date of each subdirectory, which is very slow.

Is there a faster way to combine both looping over each subdirectory and get the last modified date for each, while also getting their full path?

1

There are 1 best solutions below

0
Magoo On
FOR /f "delims=" %%b IN ('dir /b /ad "*" ') DO ECHO %%~fb^|%%~tb

where the caret escapes the pipe to reproduce the pipe as an ordinary character (column separator)