cannot find files error
3 views (last 30 days)
Show older comments
I'm being asked to carry out analysis on images withing a dataset called ImageDatasets specifically looking at a folder withing this folder called DATASET 1. I'm using the code below yet it gives me the error saying it cannot find the files. I have taken this path directly from my computer so I don't understand why it cannot find the files. All files in dataset 1 are .jpg images.
imds = imageDatastore('C:/Users/donal/Desktop/ImageDatasets/DATASET 1/*.jpg');
Can anyone help me understand where I'm going wrong?
1 Comment
Walter Roberson
on 11 Mar 2023
To debug
location = 'C:/Users/donal/Desktop/ImageDatasets/DATASET 1/*.jpg';
pieces = strsplit(location, '/');
numpieces = length(pieces);
last_valid = 0;
for K = 1 : numpieces
sofar = fullfile(pieces{1:K});
dinfo = dir(sofar);
if isempty(dinfo); break; end
last_valid = K;
end
if last_valid == 0
fprintf('NOTHING in the path was found, not even the hard disk!\n');
else
fprintf('found up to "%s"\n', sofar);
if last_valid == numpieces
fprintf('which is the entire path\n');
else
fprintf('but not "%s"\n', pieces{last_valid+1});
end
end
Answers (0)
See Also
Categories
Find more on Special Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!