Not able to cd into a folder
2 次查看(过去 30 天)
显示 更早的评论
I have to make a folder in my project and then cd into it but not able to. The code line looks like this:
name="yash";
mkdir("dB_"+name);
Then I want to cd into that folder but not able to. Please help
0 个评论
采纳的回答
Anay Aggarwal
2022-7-13
Hi Yash
I have an understanding that you want to create a folder and then cd into it while runtime.
Following might help:
name="yash";
mkdir("dB_"+name); % create a folder
cd ([ 'dB_' convertContainedStringsToChars(name) ]);
This would create a folder and cd into it while runtime.
Regards
0 个评论
更多回答(1 个)
Voss
2022-7-13
Maybe check that mkdir successfully creates the directory:
name="yash";
status = mkdir("dB_"+name)
Here status is true, so we know the directory was created.
Then cd into it:
cd("dB_"+name);
cd() % show the current working directory
If mkdir returns false, it means mkdir was not able to create the directory, maybe because you don't have write permissions in the parent directory (i.e., the directory you're in when you call mkdir).
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!