Changeset 667 for trunk/src/find_file_series.m
- Timestamp:
- Jul 15, 2013, 2:50:08 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r635 r667 20 20 % RootPath: path to the directory to be scanned 21 21 % fileinput: name (without path) of the input file sample 22 % checkxml: =1(default) take into account xml file existence to possibly include indexes in RootFile 23 % =0: do not take into account xml file existence 22 24 % 23 25 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 37 39 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 38 40 39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput )41 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml) 40 42 %------------------------------------------------------------------------ 41 43 … … 62 64 end 63 65 else 64 %% possibly include the first index in the root name, if there exists a corresponding xml file 65 r=regexp(NomType,'^(?<tiretnum>_|\d+)','names');%look for a number or _1 at the beginning of NomType 66 if ~isempty(r) %if NomType begins by a number or _1 67 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput 68 if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not detected 69 rr=regexp(fileinput_end,'^(?<i1>\d+)','names'); 70 else% if a separator '_' is detected 71 rr=regexp(fileinput_end,'^(?<i1>_\d+)','names'); 72 end 73 if ~isempty(rr) 74 RootFile_i=[RootFile rr.i1];% new root file 75 %look for an xml file correspoonding to the new root name 76 if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file')) 77 RootFile=RootFile_i; 78 NomTypePref=r.tiretnum; 79 NomType=regexprep(NomType,['^' NomTypePref],''); 80 i1_input=j1_input; 81 i2_input=j2_input; 82 j1_input=[]; 83 j2_input=[]; 84 end 66 %% if checkxml=1, possibly include the first index in the root name, if there exists a corresponding xml file 67 if ~exist('checkxml','var')||checkxml 68 r=regexp(NomType,'^(?<tiretnum>_|\d+)','names');%look for a number or _1 at the beginning of NomType 69 if ~isempty(r) %if NomType begins by a number or _1 70 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput 71 if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not detected 72 rr=regexp(fileinput_end,'^(?<i1>\d+)','names'); 73 else% if a separator '_' is detected 74 rr=regexp(fileinput_end,'^(?<i1>_\d+)','names'); 75 end 76 if ~isempty(rr) 77 RootFile_i=[RootFile rr.i1];% new root file 78 %look for an xml file correspoonding to the new root name 79 if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file')) 80 RootFile=RootFile_i; 81 NomTypePref=r.tiretnum; 82 NomType=regexprep(NomType,['^' NomTypePref],''); 83 i1_input=j1_input; 84 i2_input=j2_input; 85 j1_input=[]; 86 j2_input=[]; 87 end 88 end 85 89 end 86 90 end
Note: See TracChangeset
for help on using the changeset viewer.