-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgetfiledate.m
32 lines (30 loc) · 894 Bytes
/
getfiledate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function fileDateVector = getfiledate(fileNameIn)
%GETFILEDATE Get file modification date as serial date number.
% FILEDATE = GETFILEDATE(FILENAME) returns the modification date of the
% given file as a serial number.
%
% FILEDATES = GETFILEDATE(FILENAMECELL) works on the cell FILENAMECELL of
% file names and returns a vector of file dates.
%
% Markus Buehren
% Last modified 09.10.2008
%
% See also DIR, DATENUM2, GETFILESIZE.
if ischar(fileNameIn)
fileNameCell = {fileNameIn};
else
fileNameCell = fileNameIn;
end
fileDateVector = zeros(size(fileNameCell));
for fileNr=1:length(fileNameCell)
dirStruct = dir(fileNameCell{fileNr});
if ~isempty(dirStruct)
if isfield(dirStruct, 'datenum')
fileDateVector(fileNr) = dirStruct.datenum;
else
fileDateVector(fileNr) = datenum2(dirStruct.date);
end
else
fileDateVector(fileNr) = NaN;
end
end