only use filepath if it is a log file

I have the paths to all files in my current folder. then i want to run those files through a loop, but only if they are .log files , all other files i would like to ignore. i guess i have to find a string in a path and use an if statement, but it did not work so far
tried 'contains' and dir

 Accepted Answer

P = 'absolute or relative path to where the files are saved';
S = dir(fullfile(P,'*.log'));
for k = 1:numel(S)
F = fullfile(P,S(k).name)
..
end

More Answers (0)

Categories

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!