Effacer les filtres
Effacer les filtres

Not able to cd into a folder

2 vues (au cours des 30 derniers jours)
Yash Khandelwal
Yash Khandelwal le 13 Juil 2022
Réponse apportée : Voss le 13 Juil 2022
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

Réponse acceptée

Anay Aggarwal
Anay Aggarwal le 13 Juil 2022
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

Plus de réponses (1)

Voss
Voss le 13 Juil 2022
Maybe check that mkdir successfully creates the directory:
name="yash";
status = mkdir("dB_"+name)
status = logical
1
Here status is true, so we know the directory was created.
Then cd into it:
cd("dB_"+name);
cd() % show the current working directory
/users/mss.system.QlbB51/dB_yash
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).

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by