create new folders by mkdir()

23 visualizaciones (últimos 30 días)
osama
osama el 15 de Dic. de 2016
Comentada: kousar majeed el 16 de Jun. de 2019
i want to create new folders by mkdir() and giving(naming) it numbers sequentially folder1, folder2 .. where no repetead and how to check if folder name found skip and give next number as name for new folder .. please help ,, this part of my project and i havnt time ..

Respuesta aceptada

the cyclist
the cyclist el 15 de Dic. de 2016
Editada: the cyclist el 15 de Dic. de 2016
MAX_FOLDER_NUMBER = 10;
FOLDER_ROOT_NAME = 'folder';
for n = 1:MAX_FOLDER_NUMBER
folder_name = [FOLDER_ROOT_NAME,sprintf('%d',n)];
if not(exist(folder_name,'dir'))
mkdir(folder_name)
end
end
I tried to be very explicit about what each step is about. Also, this code checks whether the folder exists, but I don't actually think that is necessary. I don't think mkdir does anything if you try to create a directory that already exists, so you could just do
MAX_FOLDER_NUMBER = 10;
FOLDER_ROOT_NAME = 'folder';
for n = 1:MAX_FOLDER_NUMBER
mkdir([FOLDER_ROOT_NAME,sprintf('%d',n)])
end
or just
for n = 1:10
mkdir(['folder',sprintf('%d',n)])
end
if you don't want my parameterization.
  3 comentarios
osama
osama el 15 de Dic. de 2016
Another question please , how to put this cycle n=1:10 inside GUI function, cause i need to create folder every time that i start code
the cyclist
the cyclist el 15 de Dic. de 2016
I'm not quite sure what you mean. I suggest you open a new, detailed question related to the GUI, because that is quite different from this topic.

Iniciar sesión para comentar.

Más respuestas (1)

kousar majeed
kousar majeed el 12 de Jun. de 2019
i just want to create folder and name it faces
  4 comentarios
the cyclist
the cyclist el 16 de Jun. de 2019
Your code works fine for me, from a fresh start of MATLAB R2018b.
Are you certain that your code makes it to that line? For example, do you see the output of the line
disp(progIndication);
?
Are you sure you are looking for the directory Faces in the correct place -- the workspace at the moment this line runs? Also, are you looking for faces instead of Faces (case-sensitive)?
kousar majeed
kousar majeed el 16 de Jun. de 2019
i download a video from internet which is 6 to 7 min and there are 7143 images are there.
i made one folder which is frame and second folder which is faces
now i need to upload or with the help of move command to load image from frame folder with the help of GUI and show the image extract the image and crop is and save it in face folder?
need to do the above task to load image in to GUI nad extract the image

Iniciar sesión para comentar.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by