How can I search a directory and its sub directories for a file and display the file name and its created time in a neat format.
I tried dir sam.csv /b /s /a-d
But does't work.
The output should look like
c:\Data\Sam.txt 10/10/2012 10.00 AM
c:\Data\1\Sam.txt 11/10/2012 10.00 AM
c:\Data\2\Sam.txt 12/10/2012 10.00 AM
Or can I do the same in a for loop?
Try this:
for /f %f in ('dir sam.txt /s/b') do @echo %f %~tf
This is it running.
C:\data>for /f %f in ('dir sam.txt /s/b') do @echo %f %~tf
C:\data\Sam.txt 26/10/2012 10:49 a.m.
C:\data\1\Sam.txt 26/10/2012 10:49 a.m.
C:\data\2\Sam.txt 26/10/2012 10:49 a.m.
You can get more help on the FOR command using help for at the command prompt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With