Search a file in a directory using MS DOS
dos
Solution
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
Problem
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?