Hello,
I have a problem with my script. I have to create a directory like this in a for cycle:
mkdir(sprintf('c:\%i',j))
How can I create a new directory inside this? I tried :
newfolder = mkdir(sprintf('c:\%i',j))
mkdir newfolder sonfolder
But it doesn't work. Thanks for the help!

답변 (1개)

Guillaume
Guillaume 2017년 6월 2일

0 개 추천

mkdir will create all intermediate directories if necessary, so you can create the whole hierarchy with just one mkdir by passing the full path of your desired sonfolder:
mkdir(fullfile(sprintf('c:\%i', j), sonfolder);

댓글 수: 4

I tried:
mkdir(fullfile(sprintf('c:\%i',j), Funzionali));
but it doesn't work. "Funzionali" is the name of the folder
If Funzionali is the name of the folder and not a variable that holds the name, then:
mkdir(fullfile(sprintf('c:\%i', j), 'Funzionali');
or simply
mkdir(sprintf('c:\%i\Funzionali', j));
"Funzionali" is the folder inside the folder i named (sprintf('c:\%i', j).
Walter Roberson
Walter Roberson 2017년 6월 2일
Guillaume's mkdir(sprintf('c:\%i\Funzionali', j)); should work.

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

카테고리

도움말 센터 및 File Exchange에서 Search Path에 대해 자세히 알아보기

태그

질문:

2017년 6월 2일

댓글:

2017년 6월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by