diff --git a/+PlotID/createFileCopy.m b/+PlotID/createFileCopy.m index c77e3551ce3bd6bfb415fa7445af1f9f1b2d537e..3f415efb42e88e9f6fcdc3cc0fb7e7863c7ac533 100644 --- a/+PlotID/createFileCopy.m +++ b/+PlotID/createFileCopy.m @@ -42,8 +42,13 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type) % TODO add more inteligent way then a simple sufix count = count + 1; [~,name,ext] = fileparts(RemotePath); - RemotePath = fullfile(storPath,folderName,... - [name,'_',num2str(count),ext]); + if count < 2 + RemotePath = fullfile(storPath,folderName,... + [name,'_',num2str(count),ext]); + else + RemotePath = fullfile(storPath,folderName,... + [name(1:end-length(num2str(count))),num2str(count),ext]); + end warning('Filename already exists in data folder'); end copyfile(FileNameAndLocation,RemotePath); diff --git a/.gitignore b/.gitignore index abeaca835870ce4831818cafc139a05bcf6da698..ddff5632c230d645711f17c10ad1aeff30189703 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,10 @@ codegen/ test*.m test123_data.h5 + # files that are created in example.m testdata_2.h5 +testdata2.h5 test_data.mat export/* diff --git a/PlotID_Demo.m b/PlotID_Demo.m index ac720c08582050a3f2f4fbd8f11a9d4262103902..2914c4f68f4d0b98cf3bac0d30527d77f9149fd7 100644 --- a/PlotID_Demo.m +++ b/PlotID_Demo.m @@ -5,7 +5,7 @@ clear; clc; close all; addpath('CI_files'); % Test scripts try - delete testdata_2.h5; + delete testdata2.h5; end %% Set ProjectID @@ -28,8 +28,8 @@ y1 = sin(x1)+.5*sin(2*x1)+2; % define file path & name -fpath = fullefile(pwd,"./testdata_2.h5"); -dataset2 = fullfile(pwd,'testdata_2.h5'); +fpath = fullefile(pwd,"./testdata2.h5"); +dataset2 = fullfile(pwd,'testdata2.h5'); % create hdf5 file and dataset > write data to hdf5 file / dataset h5create(fpath, "/x1", size(x1), "Datatype", class(x1)) diff --git a/example.m b/example.m index c73c83a0963179e3b77843ae6ff70dde8f293dd1..dfb5647fb28923605f61033f8e0b832b221b3333 100644 --- a/example.m +++ b/example.m @@ -6,7 +6,7 @@ clear; clc; close all; addpath('CI_files'); % Test scripts try - delete testdata_2.h5; + delete testdata2.h5; end @@ -37,7 +37,7 @@ x1 = linspace(0,2*pi); y1 = sin(x1)+2; % define file path & name -dataset2 = 'testdata_2.h5'; +dataset2 = 'testdata2.h5'; dataset2 = fullfile(pwd,dataset2); fpath = dataset2;