how to use command "dir"

조회 수: 6 (최근 30일)
zhang
zhang 2011년 11월 23일
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

답변 (2개)

Oleg Komarov
Oleg Komarov 2011년 11월 23일
You can look for a specific extension:
dir 'C:\Users\Oleg\Desktop\*.jpg'
  댓글 수: 1
zhang
zhang 2011년 11월 23일
what if there are many different file types?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 11월 23일
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.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by