App designer: How to select multiple folders

15 visualizaciones (últimos 30 días)
Sarlota Duskova
Sarlota Duskova el 25 de Sept. de 2020
Editada: Mario Malic el 25 de Sept. de 2020
Hello,
At the begin I want tell you that I am using Matlab R2020b, I made an app where i am using uigetfile with MultiSelect on and I am working with csv files. My question is that i have one main folder whiche you can see in the picture below, the folder name is 2020-04-08 and it has many subfolders, I need to get csv files from subfolder bot_01 and take all csv files, then I want to print plot from these data and then go to the another subfolder bot_02 and take all csv files and so on. My app is working when I choose multiple files by uigetfile, but then I am able to use only two csv files from 2020-03-02, but not all from bot_01. Is it there some function that I can select multiple subfolder for example all subfolder from bot_01 and then get csv files? Or can I extract all csv from bot_01 to new folder which will name bot_01_all or something like that and do it by loop for all folders like bot_02, bot_03 and so on, and then use uigetfile with MultipleSelect and get all csv files from new folder call bot_01_all and so on? Because it is annoying do it by my self and every time copy csv files from subfolders to one folder calls for example bot_01_all.

Respuesta aceptada

Mario Malic
Mario Malic el 25 de Sept. de 2020
Editada: Mario Malic el 25 de Sept. de 2020
Depending on what's inside of data, here's a suggestion:
Path = dir('**/*.csv'); % generates structure that contains csv files within current folder
% and subfolders
If the files may have same names in different subfolders, then you can get folder names with
List_Folders = {Path.folder}';
You can remove folders that have the same name with
List_Uni_Folders = unique(List_Folders)
Since you plot data from each subfolder, you can use sprintf within loop
for
Dir_Path = sprintf('%s\\*.csv', List_Uni_Folders{counter,1}) % Folder path that changes in loop
Files_Sep_Folder = dir(Dir_String) % this outputs structure of all csv files within Dir_Path
Analysed_File = [Files_Sep_Folder(counter,1).folder, '\', Files_Sep_Folder(counter,1).name] % gives a path of a single file
%plot commands
end
The variables names might be a little bit silly, so adjust to your liking.

Más respuestas (0)

Categorías

Más información sobre Large Files and Big Data en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by