필터 지우기
필터 지우기

create new folders by mkdir()

조회 수: 21 (최근 30일)
osama
osama 2016년 12월 15일
댓글: kousar majeed 2019년 6월 16일
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 ..

채택된 답변

the cyclist
the cyclist 2016년 12월 15일
편집: the cyclist 2016년 12월 15일
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
osama
osama 2016년 12월 15일
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 2016년 12월 15일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

kousar majeed
kousar majeed 2019년 6월 12일
i just want to create folder and name it faces
  댓글 수: 4
the cyclist
the cyclist 2019년 6월 16일
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 2019년 6월 16일
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

댓글을 달려면 로그인하십시오.

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by