-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinaryComparison.m
More file actions
64 lines (52 loc) · 1.8 KB
/
Copy pathbinaryComparison.m
File metadata and controls
64 lines (52 loc) · 1.8 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function binaryComparison
%BINARYCOMPARISON Summary of this function goes here
% Detailed explanation goes here
mainDir = '\\root\programs\Outreach-Education\Light_and_Health_Inst\daysimeter_2016-10-18';
mainListing = dir(mainDir);
mainListing(~[mainListing.isdir]') = [];
parentIdx = strcmp({mainListing.name}','.') | strcmp({mainListing.name}','..');
mainListing(parentIdx) = [];
dirArray = fullfile(mainDir,{mainListing.name}');
for iDir = 1:numel(dirArray)
thisDir = dirArray{iDir};
listing = dir([thisDir,filesep,'*DATA.txt']);
fileNameArray = {listing(:).name};
filePathArray = fullfile(thisDir,fileNameArray);
varNameArray = matlab.lang.makeValidName(regexprep(fileNameArray,'([^a-zA-Z0-9]*)','_'));
T = initTable(varNameArray);
n = numel(listing);
for i1 = 1:n
for j1 = 1:n
if j1 == i1
continue;
end
filePath1 = filePathArray{i1};
filePath2 = filePathArray{j1};
if isDiff(filePath1,filePath2)
T.(j1)(i1) = {'diff'};
else
T.(j1)(i1) = {'same'};
end
end
end
timestamp = datestr(now,'yyyy-mm-dd_HHMM');
excelPath = fullfile(thisDir,['comparison_',timestamp,'.xlsx']);
try
writetable(T,excelPath,'WriteRowNames',true);
catch err
display(err.message)
end
end
end
function T = initTable(varNameArray)
n = numel(varNameArray);
T = cell2table(cell(n,n));
T.Properties.VariableNames = varNameArray;
T.Properties.RowNames = varNameArray;
T.Properties.DimensionNames = {'file1','file2'};
end
function TF = isDiff(filePath1,filePath2)
file_1 = javaObject('java.io.File', filePath1);
file_2 = javaObject('java.io.File', filePath2);
TF = ~javaMethod('contentEquals','org.apache.commons.io.FileUtils',file_1, file_2);
end