I have a series of folders (for example, 50 folders), each with its unique name (completely different names). I want to extract a set of information from each of these folders (from an Excel file). The final output should be an Excel file, that contain all the information extracted from the 50 folders. The data are not numbers. They are E-mails of stuffs. Finally, it should remove duplicate data.
The only common aspect among these 50 folders is that they all contain a folder named "A", and inside this folder, all the necessary information (Excell file with the Emails I want to collect) is placed.
Can anyone help me with this? Thanks in advance.

2 Kommentare

Image Analyst
Image Analyst am 21 Apr. 2023
You posted so soon I really doubt you even had time to run my demos below..

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 21 Apr. 2023

1 Stimme

See some file and folder demos, attached. Adapt as needed.

4 Kommentare

civil tech
civil tech am 21 Apr. 2023
I need more help for my task please.
Try this. Adapt as needed to do whatever you want with the data read in from the Excel files.
% Optional initialization steps
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
% Specify the folder where the files live.
myFolder = fullfile(pwd, 'MainFolder'); % or 'C:\Users\whatever\';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder);
uiwait(warndlg(errorMessage));
myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0
% User clicked Cancel
return;
end
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '**\*.xlsx'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
allFileNames = fullfile({theFiles.folder}, {theFiles.name})
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
% Read in the next image.
fprintf(1, 'Now reading #%d of %d : "%s"\n', k, length(theFiles), fullFileName);
data = readmatrix(fullFileName);
% Now do something with data.
end
civil tech
civil tech am 22 Apr. 2023
Thank you so much for your kind help.
Image Analyst
Image Analyst am 22 Apr. 2023
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by