how to use command "dir"

6 visualizaciones (últimos 30 días)
zhang
zhang el 23 de Nov. de 2011
Hi guys,
When using command "dir", there always includes '.', '..'.
Is there a way to eliminate these two items when using command "dir"(not postprocess)?
Thanks,
Zhong

Respuestas (2)

Oleg Komarov
Oleg Komarov el 23 de Nov. de 2011
You can look for a specific extension:
dir 'C:\Users\Oleg\Desktop\*.jpg'
  1 comentario
zhang
zhang el 23 de Nov. de 2011
what if there are many different file types?

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 23 de Nov. de 2011
You can only do that by telling dir() to match the things that you do want, rather than getting the list of everything and throwing away what you do not want.
For example, dir('*.mat') instead of dir('*') and assuming that everything you get back will be a .mat file.
If you are using dir('*') you should be putting in protective checks for '.' and '..' and for sub-directories (folders) and for (e.g.,) README.txt files that describe the content of the directory.

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by