HOW TO CREATE A FOLDER WITH DIFFERENT NAMES AND A SUBFOLDER FOR EACH FOLDER

조회 수: 12 (최근 30일)
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

채택된 답변

Adam Danz
Adam Danz 2019년 3월 12일
편집: Adam Danz 2019년 3월 12일
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개)

카테고리

Help CenterFile Exchange에서 Oil, Gas & Petrochemical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by