diff --git a/fcn_core/Publish.m b/fcn_core/Publish.m index 75473df7bdd13f006753b225ce2b19b41c60c392..4fd760ab225374b52f549917ea0955913f776c42 100644 --- a/fcn_core/Publish.m +++ b/fcn_core/Publish.m @@ -69,7 +69,7 @@ switch options.Method sourcePath = fList.name{idx}; createLinkedHDF5(sourcePath,storPath,ID); else % no identical file exists - createFileCopy(DataPaths.rdata,'data',storPath,ID,'dataCentral'); + createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'dataCentral'); end end case 'individual' diff --git a/fcn_help/createFileCopy.m b/fcn_help/createFileCopy.m index 67b16204ff7463ac32d3c69b4f1d31da0442c2ef..19b278ca51d17b588b6eac98ae35d18ed3995653 100644 --- a/fcn_help/createFileCopy.m +++ b/fcn_help/createFileCopy.m @@ -2,7 +2,12 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type) % Creates a copy of the files (can used for multiple paths in a cell array) % folderName is the name of the exporting folder disp(['start to copy ', type]); - + + if ~iscell(filePaths) + %fixes Issue if Filepath is a char and not a cell array + filePaths = {filePaths}; + end + % try for i = 1:numel(filePaths) FileNameAndLocation = filePaths{i}; @@ -28,15 +33,15 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type) % Write the file RemotePath = fullfile(storPath,folderName, newfile); - % Check if remote file already exists (not working) -% count = 0; -% while isfile(RemotePath) && ismember(type,{'data','dataCentral'}) -% % Add a Sufix number to file name -% count = count + 1; -% [~,name,ext] = fileparts(RemotePath); -% RemotePath = fullfile(storPath,folderName,... -% [name,'_',num2str(count),ext]); -% end +% Check if remote file already exists + count = 0; + while isfile(RemotePath) && ismember(type,{'data','dataCentral'}) + % Add a Sufix number to new file name + count = count + 1; + [~,name,ext] = fileparts(RemotePath); + RemotePath = fullfile(storPath,folderName,... + [name,'_',num2str(count),ext]); + end copyfile(FileNameAndLocation,RemotePath); end disp([type, ' sucessfully published']);