Reading date of a file
8 views (last 30 days)
Show older comments
I'm trying to obtain a date of creation of a file with :
[dum,str] = dos('dir myfile.txt');
c = textscan(str,'%s');
createdate = c{1}{15}
but I want to put my Matlab variable as in :
[dum,str] = dos('dir', strcat(myfile));
c = textscan(str,'%s');
createdate = c{1}{15}
disp(createdate);
And it doesnt work, how do I do it ??
Cheers
Damian
0 Comments
Accepted Answer
Kelly Kearney
on 21 Jul 2014
Why not just use dir?
A = dir(myfile);
disp(A.date)
But if you want to call the dos command:
[dum, str] = dos(sprintf('dir %s', mfile));
c = textscan(str,'%s');
createdate = c{1}{15};
disp(createdate);
2 Comments
Kelly Kearney
on 21 Jul 2014
Use datestr:
str = datestr(A.datenum, 'dd-mm-yyyy HH:MM:SS');
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!