HOW TO CREATE A FOLDER WITH DIFFERENT NAMES AND A SUBFOLDER FOR EACH FOLDER
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daniel Boateng
el 12 de Mzo. de 2019
I want to create different folders with name simulation_Data1,simulation_Data2,simulation_Data3 and so on and each folder I want to have a subfolder called real_Data in every simulation_Data Folder. Please how do i go about this.
maximum_Folder = 10;
ROOT_FOLDER = 'Simulation_Data';
for n = 1:MAX_FOLDER_NUMBER
folder_name = [ROOT_FOLDER,sprintf('%d',n)];
mkdir([Name_Project_folder \'folder_name'\'Real_Data'])
if not(exist(folder_name,'dir'))
mkdir(folder_name)
end
end
0 comentarios
Respuesta aceptada
Adam Danz
el 12 de Mzo. de 2019
Editada: Adam Danz
el 12 de Mzo. de 2019
At the top, define the parent directory (the directory where your simulation data folders will go). Then set the number of simulation data folders to be created. The code will loop through each new folder and create the simulation_datax folder and the real_data subfolder. If the simulation data folder already exists, the iteration will be skipped.
parentdir = 'C:\Users\hristobotev\Documents\MATLAB\mydata'; %parent directory
maximum_Folder = 10; %number of simulation_Data folders to create
ROOT_FOLDER = 'simulation_Data'; %base name for folder 1
f2name = 'real_Data'; %base name for folder 2
for n = 1:maximum_Folder
newfolder = fullfile(parentdir, sprintf('%s%d', ROOT_FOLDER, n));
status = mkdir(newfolder);
if status
mkdir(fullfile(newfolder, f2name));
end
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Filename Construction en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!