-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_dataset_names.m
41 lines (31 loc) · 953 Bytes
/
get_dataset_names.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
function [nameShort, cd, name] = get_dataset_names(subfolder,spaces)
if ~exist('subfolder','var')
subfolder = 'text';
end
if ~exist('spaces','var')
spaces = 0;
end
% if this isn't windows, crash...
if ~strcmp(computer('arch'),'win64')
% this is windows specific due variable behavior of MATLAB's ls command
error('get_dataset_names() is only compatible with windows machines!');
end
% get all text files in the subfolder
nameVector = ls(subfolder);
name = cell(size(nameVector,1)-2,1); nameShort = name;
for ii = 1:length(name)
% get current string
name{ii} = nameVector(ii+2,:);
% get rid of extension and/or spaces
if spaces
nameShort{ii} = name{ii};
nameShort{ii}(nameShort{ii} == ' ') = [];
else
nameShort{ii} = name{ii}(1:find(name{ii} == '.')-1);
end
end
% get paths
cd = cell(length(name),1);
for ii = 1:length(cd)
cd{ii} = [pwd '\' subfolder '\' name{ii}];
end