How I can store all images name in an excel sheet?

My folder consisting of multiple binary images. I want to store their names in an excel sheet along with all their extracted features.

Answers (1)

Try this:
fileInfo = dir('*.PNG');
ca = struct2cell(fileInfo)
baseFileNames = ca(1,:)'
xlswrite(excelFullFileName, baseFileNames);

8 Comments

Image Analyst:when I am adding the path of my existing folder it's not able to execute.
I have no idea what you did. The code I gave should execute. Do you want the full file names (path plus base filename plus extension)?
Try this:
fileInfo = dir('*.PNG');
% fullFileNames = cell(1, length(fileInfo)); % If you want it to go into one row of Excel.
fullFileNames = cell(length(fileInfo), 1); % If you want it to go into one column of Excel.
for k = 1 : length(fileInfo)
fullFileNames{k} = fullfile(fileInfo(k).folder, fileInfo(k).name);
end
% Write to Excel
xlswrite(excelFullFileName, fullFileNames);
fileInfo = dir(fullfile('D:\data_set.PNG'));
% fullFileNames = cell(1, length(fileInfo)); % If you want it to go into one row of Excel.
fullFileNames = cell(length(fileInfo), 1); % If you want it to go into one column of Excel.
for k = 1 : length(fileInfo)
fullFileNames{k} = fullfile( fileInfo(k).name);
end
% Write to Excel
xlswrite('aa.xlsx', fullFileNames);
This is not working when adding the path
That is not a folder of many binary images. You passed in one single image, data_set.png. Nonetheless, it should work as long as that one image is there. in the root folder of your D drive.
data_set is my folder. It also showing error when am passing fileInfo(k).data_set
Reference to non-existent field 'folder'.
Error in name_save (line 5) fullFileNames{k} = fullfile(fileInfo(k).folder, fileInfo(k).name);
>> This is the error I am getting.

Sign in to comment.

Asked:

on 5 May 2018

Commented:

on 6 May 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!