Can MATLAB create subfolders within subfolders, programmatically?
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu File Operations finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!