Home How to select files that don't contain a certain string in MATLAB?
Reply: 0

How to select files that don't contain a certain string in MATLAB?

user545
1#
user545 Published in April 21, 2018, 4:01 am

I have a directory with 10000 files. I want to select those files for processing that don't contain the string "_B". There are other files with the character B that I don't want to exclude.

I tried to do the following:

for k=1:n
    if(~contains(files(k).name, '*_B*.png'))
    ...
end

But this just selects all the files with "_B" instead. If I remove the tilde in front of "contains", none of the files are getting selected. What do I change the line into to get the desired results?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309285 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO