参考
- ?matlab怎么读取文件的创建、访问、修改日期 – MATLAB中文论坛
- file - Set modification time in matlab - Stack Overflow
>> f = dir('my_filename.dat');
>> f.date
??????3.?FileTime - File Exchange - MATLAB Central
? ? ? ? 参考上述链接的函数,the C-file has to be compiled before it can be used. ????????At first setup your compiler by "mex -setup", if not done before. Then compile as mentioned ????????in the C-file: "mex -O GetFileTime.c" and "mex -O SetFileTime.c".
? ? ? ? 函数引用:
? ? ? ?Time = GetFileTime(FileName, TimeType(可选), OutputType(可选))
? ? ? ? 结果如下: ? ????????? Creation: [2021 11 13 21 11 1.8750] ? ????????? ? Access: [2021 11 13 21 21 20.0600] ? ? ????????? ?Write: [2014 2 12 13 32 18]
? ? ? ?4.?How can I concatenate or merge two structures? - MATLAB Answers - MATLAB Central
应用场景
批量读取文件,确认指定日期后修改的文件;
%设定文件修改检查的时间点
DateString = '2014/02/11/13:33';
formatIn = 'yyyy/mm/dd/HH:MM'; %年月日时分
timeStampCheck = datenum(DateString,formatIn);
%所有m、c类型文件(包括子文件夹)
FileInfo_m = dir('**/*.m');
FileInfo_c = dir('**/*.c');
mergestructs = @(x,y) cell2struct([struct2cell(x),struct2cell(y)],fieldnames(x),1);
FileInfo = mergestructs(FileInfo_m,FileInfo_c);
%显示设定时间点之后更新的文件
idx = [FileInfo.datenum]>timeStampCheck;
{FileInfo(idx).name; FileInfo(idx).date}'
|