Clear Filters
Clear Filters

Cannot find files or folders matching: 'recycle10​1\project\​aluminiumc​an'.

5 views (last 30 days)
clc
clear all; close all;
outputFolder=fullfile('recycle101');
rootFolder=fullfile(outputFolder,'project');
categories={'aluminiumcan','petbottles','drinkcartonbox'};
imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
tbl=countEachLabel(imds)
Error:
>> imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
tbl=countEachLabel(imds)
Error using imageDatastore
Cannot find files or folders matching: 'recycle101\project\aluminiumcan'.
  4 Comments
Tan
Tan on 13 May 2023
but my MATLAB install at hard-disk and the dataset is saved at local disk.
Does it will affect and get the error as below?
Error using imageDatastore
Cannot find files or folders matching: 'recycle101\project\aluminiumcan'.
Walter Roberson
Walter Roberson on 13 May 2023
what does this report?
parts = {'recycle101', 'project', 'aluminiumcan'};
if exist(parts{1}, 'dir')
fprintf('folder "%s" exists!\n', parts{1});
if exists(fullfile(parts{1:2}), 'dir')
fprintf('folder "%s" exists!\n', fullfile(parts{1:2}));
if exists(fulfile(parts{1:3}), 'dir')
fprintf('folder "%s" exists!\n', fullfile(parts{1:3}));
else
fprintf('but could not find subfolder "%s"\n', parts{3});
end
else
fprintf('but could not find subfolder "%s"\n', parts{2});
end
else
fprintf('folder "%s" does not exist in current directory!\n', parts{1});
end

Sign in to comment.

Answers (1)

Neeraj
Neeraj on 22 May 2023
Hello,
The error clearly states that 'imageDatastore' is unable to find the files/folders located at location 'recycle101\project\aluminiumcan'
Please ensure that the relative path: 'recycle101\project\aluminiumcan' exists.
If it does exist, then try to pass the absolute path to the 'imageDatastore' which might look similar to: 'C:\Users\OneDrive\Desktop\recycle101\project\aluminiumcan'
If the absolute path works without any error, then you only need to modify the 'outputFolder' variable as shown below:
clc
clear all; close all;
outputFolder=fullfile('C:\Users\OneDrive\Desktop\recycle101');
rootFolder=fullfile(outputFolder,'project');
categories={'aluminiumcan','petbottles','drinkcartonbox'};
imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
tbl=countEachLabel(imds)

Categories

Find more on File Operations 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!