Naming new directories sequentially

Hello,
I am trying to figure out how to make new folders with a prefix and sequentially number them. I would like them to all contain the same sub directories:
Prefix_001
Subdirectory A
Subdirectory B
Prefix_002
Subdirectory A
Subdirectory B
Prefix_003
Subdirectory A
Subdirectory B

 Respuesta aceptada

Stephen23
Stephen23 el 20 de Mayo de 2021
N = number of directories
P = 'absolute/relative path to the parent directory';
for k = 1:N
D = sprintf('Prefix_%03d',k);
mkdir(fullfile(P,D))
mkdir(fullfile(P,D,'Subdirectory A'))
mkdir(fullfile(P,D,'Subdirectory B'))
end

1 comentario

Nadeau Hahne
Nadeau Hahne el 20 de Mayo de 2021
Perfect, thank you, I am new to scripting, this was super helpful!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 20 de Mayo de 2021

Comentada:

el 20 de Mayo de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by