Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

read file names of files beyond a specific size into a vector

Asked by Shuster on 4 Nov 2012

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 Comment

José-Luis on 4 Nov 2012

136b? What does that mean? Do you want a number or a string?

Shuster

Tags

Products

No products are associated with this question.

2 Answers

Answer by Jan Simon on 4 Nov 2012
Accepted answer

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 Comments

Jan Simon
Answer by Walter Roberson on 4 Nov 2012

http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

One of the fields returned by dir() is the file size.

dirinfo([dirinfo.bytes <= 136]) = [];   %removes info for files 136 bytes or less

0 Comments

Walter Roberson

Contact us