Can MATLAB create subfolders within subfolders, programmatically?
Show older comments
I’m attempting to create a file structure using the following code;
% Make the Junk folder the current folder
cd Junk;
% Ask the user for the directory to be created in the Junk folder, and
% then make it
New_Dir = input('Enter directory name of this event: ', 's');
New_Directory = fullfile('C:', 'Documents and Settings', 'bonstott', 'My Documents', 'MATLAB', 'Junk', New_Dir);
mkdir(New_Directory);
% Change the current folder to the New_Directory and create the subfolders
cd(New_Directory);
mkdir('Plasma');
% Assign the ID numbers a name and place them in the selected folders.
Num_IDs = input('Enter the number of IDs: ');
for j = 1:Num_IDs
Sub_Dir_Name = input('Enter ID number: ', 's');
mkdir('Plasma', Sub_Dir_Name);
end
% create the subfolders within Plasma
cd(New_Directory);
cd Plasma;
mkdir('Vs L');
mkdir('Vs O');
With New_Dir = Test and Num_IDs = 1, the following structure is created;
C:\Documents and Settings\bonstott\My Documents\MATLAB\Junk\Test\Plasma\
1
Vs L
Vs O
But the desired structure is;
C:\Documents and Settings\bonstott\My Documents\MATLAB\Junk\Test\Plasma\1
Vs L
Vs O
Is there a way to create the desired structure, programmatically?
Accepted Answer
More Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!