read file names of files beyond a specific size into a vector
조회 수: 4 (최근 30일)
이전 댓글 표시
i have a bunch ('n') of files named in the following way
asdfxxxxxx_pqrs.txt
where xxxxxx stands for 6 digit zero padded number
ex : xxxxxx can be any of 000000 000001 000002 000003 . .
Of these files, all of ~136b but rest of not. I need to read the numbers (without zero padding) of those files that are larger than 136b into a vector
댓글 수: 1
채택된 답변
Jan
2012년 11월 4일
If "136b" means a file size of 136 Bytes:
list = dir(fullfile(YourPath, 'asdf??????_pqrs.txt')
FileSize = [list.bytes];
FileName = {list(FileSize > 136).name};
Worm = sprintf('%s*', FileName{:});
Number = sscanf(Worm, 'asdf%d_pqrs.txt*');
댓글 수: 0
추가 답변 (1개)
Walter Roberson
2012년 11월 4일
One of the fields returned by dir() is the file size.
dirinfo([dirinfo.bytes <= 136]) = []; %removes info for files 136 bytes or less
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!