MATLAB: Is it possible to obtain the creation date of a directory or file in MATLAB 7.5 (R2007b)

attributecreatecreationdatedirectoryfileMATLABpropertiespropertytime

I am trying to obtain the creation date of a directory or a file. I am able to obtain the modification date of a file by using the DIR command. For example:
d = dir('myfile.txt');
moddate = d.date;
I want to know if there is a similar command that returns the creation date.

Best Answer

The ability to directly obtain the file or directory creation date is not available in MATLAB.
As a workaround, use the operating system interface to obtain the creation date of a file or directory. The DOS command allows one to execute functions from the Windows system shell. DIR then gives the file information stored by the operating system. For example, if your working directory contains the file 'myfile.txt' you may execute the following to obtain the creation date of 'myfile.txt':
[dum,str] = dos('dir myfile.txt');
It is then necessary to parse the string, 'str', which is returned from the operating system. This can be done using the TEXTSCAN command. For example:
c = textscan(str,'%s');
createdate = c{1}{15}
Note that proper indexing into the variable 'c' may be platform dependent.
In order for the same MATLAB code to work on a Linux platform, the function ISPC can be used to determine whether the code is running on a PC or Linux platform. On Linux, the commands UNIX and LS work analogously to DOS and DIR.