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

 Respuesta aceptada

Kelly Kearney
Kelly Kearney el 21 de Jul. de 2014

1 voto

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 comentarios

Damian
Damian el 21 de Jul. de 2014
Editada: Damian el 21 de Jul. de 2014
I used the shorter option, thanks, and since I'm in Poland I see here something like :
07-lip-2014 03:35:30
I want to store it, but how would I make it look like
07-07-2014 03:35:30
??
do I need to take care of all the cases of 12 months now ??
Kelly Kearney
Kelly Kearney el 21 de Jul. de 2014
Use datestr:
str = datestr(A.datenum, 'dd-mm-yyyy HH:MM:SS');

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 21 de Jul. de 2014

Comentada:

el 21 de Jul. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by