-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtotalFolderBuilder_v22.m
69 lines (51 loc) · 1.84 KB
/
totalFolderBuilder_v22.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
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
65
66
67
68
%% totalFolderBuilder_v22.m
% This function builds the folder structure for storing the converted nc files
% for total data and the full filename of the converted nc total file,
% according to the structure YYYY/YYYY_MM/YYYY_MM_DD/.
% INPUT:
% mainPath: root path for total nc folder.
% ts: timestamp of the total file
% OUTPUT:
% tFB_err: error flag (0 = correct, 1 = error)
% fullPath: full path of the folder where to store the converted nc
% total file.
% Author: Lorenzo Corgnati
% Date: September 28, 2020
% E-mail: [email protected]
%%
function [tFB_err,fullPath] = totalFolderBuilder_v22(mainPath,ts)
disp(['[' datestr(now) '] - - ' 'totalFolderBuilder_v22.m started.']);
tFB_err = 0;
fullPath = '';
warning('off', 'all');
% Retrieve the time-related elements of the path
try
[yMDF_err,yearFolder,monthFolder,dayFolder] = yearMonthDayFolder(ts);
catch err
disp(['[' datestr(now) '] - - ERROR in ' mfilename ' -> ' err.message]);
tFB_err = 1;
return
end
% Create the folder structure
% Version v2.2
try
if (exist([mainPath filesep 'v2.2' filesep yearFolder], 'dir') ~= 7)
mkdir([mainPath filesep 'v2.2' filesep yearFolder]);
end
if (exist([mainPath filesep 'v2.2' filesep monthFolder], 'dir') ~= 7)
mkdir([mainPath filesep 'v2.2' filesep monthFolder]);
end
if (exist([mainPath filesep 'v2.2' filesep dayFolder], 'dir') ~= 7)
mkdir([mainPath filesep 'v2.2' filesep dayFolder]);
end
catch err
disp(['[' datestr(now) '] - - ERROR in ' mfilename ' -> ' err.message]);
tFB_err = 1;
return
end
% Build the full filename for the nc total file
fullPath = [mainPath filesep 'v2.2' filesep dayFolder];
if(tFB_err==0)
disp(['[' datestr(now) '] - - ' 'totalFolderBuilder_v22.m successfully executed.']);
end
return