Question

I need to get a file information (its size and last update time) using system command system ("dir") , but it gives me many information that I don't want.

How can i get it to display only this info?

Was it helpful?

Solution

use system ("dir /4 /T:W YOURFILE | findstr YOURFILE > temp.txt") and you will get an output like:

C:\> dir /4 /T:W log.txt | findstr log.txt > t.txt
03/25/2014  10:39 AM           451,282 log.txt

in temp.txt, which you can parse as a normal file :P

/4 shows four characters for the year, /T:W returns last write time

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top