Exist returning zero when file definitely exists; rehash not working
조회 수: 3 (최근 30일)
이전 댓글 표시
I have written a script to help organize my files, the main point of which is to group all graphics of a certain type into one folder (which is made in the execution of the script), and same with other graphics.
Unfortunately I have many folders to do this in, and they are not uniformly filled with the same file types. So I am trying to find out if certain graphics exist, but I get a negative answer if I use a wildcard, where specific file names get a positive:
>> exist([Directory,'01-Oct-2009_1.jpeg'])
ans =
2
>> exist([Directory,'*.jpeg'])
ans =
0
I've tried using rehash and rehash path and neither works. Any idea how I can fix this?
댓글 수: 0
채택된 답변
Jian Wei
2014년 7월 26일
To find out if there is any JPEG file in the Directory folder, you can use the wildcard character as follows.
isempty(dir([Directory,'*.jpeg']));
댓글 수: 0
추가 답변 (1개)
Ahmet Cecen
2014년 7월 25일
I am not sure why the wildcar doesn't work. How about using the wildcard with dir beforehand and searching within the matlab matrix?
files = dir('*.jpeg');
This should get you and extensive list of every jpeg in the folder.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!