Why is the command dir inconsistent about recognizing directories?
Mostra commenti meno recenti
Hi All,
I have an application that stores setup data in a specific folder. When it starts it looks to see if that folder exists so it can load the current data. If not it creates the folder and saves default settings. My script was working just fine last week, and today for some reason, it doesn't recognize the folder that it creates as a directory. Specifically if I call d=dir;, and i is the instance of the folder (that I can see in Windows Explorer), then d(i).name is the name of the folder, but d(i).isdir returns a 0. Here's some of the code:
d = dir;
create_data_folder = 1;
for i=1:length(d)
fprintf('The name is %s and isdir is %d\n',d(i).name,d(i).isdir)
if d(i).isdir
if strcmp(d(i).name, 'Folder Name')
create_data_folder = 0;
fprintf('Starting up.\n');
end
end
end
After this, if create_data_folder is 1, it uses a mkdir command to create the folder "Folder Name". Once it's there, sometimes it recognizes it as a directory and sometimes it doesn't! I'd appreciate it if anyone has any ideas. Thanks.
Glenn
1 Commento
Cedric
il 9 Apr 2013
Did you try to see what EXIST returns using the 'kind' argument 'dir' and 'file'?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su File Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!