Strange behavior retrieving directories' names with dir
Show older comments
I am trying to extract the names of the subdirectories contained in one directory. For example:
mainDirectory
matlabScript.m
results
subdirectory1
subdirectory2
subdirectory3
subdirectory4
I am running the following in matlabScript.m :
subdirectories = dir([pwd filesep results filesep]);
In theory, I should get a structure with 4 elements, one for each subdirectory. However, I am getting 6 elements. Of these, 4 are the desired subdirectories, but the other two are two mysterious subdirectories:
name: '.'
date: '30-sep-2011 10:09:14'
bytes: 0
isdir: 1
datenum: 7.3478e+005
name: '..'
date: '27-sep-2011 19:51:12'
bytes: 0
isdir: 1
datenum: 7.3477e+005
I am pretty sure I do not have this directories. I already read the documentation of dir ant nothing is stated. I also changed the OS properties to show any hidden folders and not even with that I found them. How can I correct this strange behavior? I am running MATLAB R2010b in a computer with Windows 7, 64 bits.
Thanks in advance
Accepted Answer
More Answers (1)
Grzegorz Knor
on 30 Sep 2011
This is not a strange behaviour:
. - is a current directory, type:
cd .
and .. is a parent directory, type:
cd ..
2 Comments
Grzegorz Knor
on 30 Sep 2011
See also:
http://en.wikipedia.org/wiki/Path_%28computing%29
Adriano
on 30 Sep 2011
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!