forked from bettachini/fiberGNLSE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpFileNameNext.m
58 lines (53 loc) · 2.01 KB
/
expFileNameNext.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
function [ FileName, ResultsPath ] = expFileNameNext( varargin )
%expFileNameNext Summary of this function goes here
% Adds 1 to qq number in position LeadChar
% yymmdd05mat.mat= FileNameNext(ResultsPath, yymmdd04mat.mat, 7)
% if no base directory and filename given, start own
switch nargin()
case 0
date_str= datestr(now,20);
date_str= strcat( date_str(7:8), date_str(4:5), date_str(1:2) );
day_count= 001;
FileName= strcat( date_str, num2str(day_count, '%.3i') ); %% yymmddqqq (7 LeadChar)
qNumber= 3;
LeadChar= 7; % qqq position in FileName yymmddqqq string
% Base directory for results
cd ..
curr= pwd;
ResultsPath= [curr '/results/'];
files= dir(ResultsPath);
cd codes
case 2
FileName= varargin{1};
ResultsPath= varargin{2};
qNumber= 3;
LeadChar= 7; % qqq position in FileName yymmddqqq string
files= dir(ResultsPath); % reads ResultsPath file names
day_count= str2num(FileName(LeadChar:LeadChar+ qNumber- 1) );
case 3
FileName= varargin{1};
ResultsPath= varargin{2};
qNumber= varargin{3};
LeadChar= 7; % qqq position in FileName yymmddqqq string
files= dir(ResultsPath); % reads ResultsPath file names
day_count= str2num(FileName(LeadChar:LeadChar+ qNumber- 1) );
case 4
FileName= varargin{1};
ResultsPath= varargin{2};
qNumber= varargin{3};
LeadChar= varargin{4};
files= dir(ResultsPath); % reads ResultsPath file names
day_count= str2num(FileName(LeadChar:LeadChar+ qNumber- 1) );
end
% checks if filename was used, in that case increases day_count
Narch= size(files,1);
for i=3:Narch
CurrFile= files(i).name;
if (size(CurrFile,2)>= LeadChar+ qNumber- 1)
if strcmp(CurrFile(1:LeadChar+ qNumber- 1), FileName)
day_count= day_count+ 1;
FileName= strcat(FileName(1: LeadChar- 1), num2str(day_count, '%.3i') );
end
end
end
end