Store directory listing into loopable structure

1 view (last 30 days)
Hello,
I am trying to collect the output of dir below into a folder/dataset/structure that I can loop through.
cd 'C:\Users\dbhadra\Desktop\MSD\Sensor Mixing\Pr14 Ryan Data\TC2\RT\Closed_Loop'
dir **/*RT06*.dat
The command line looks like
Files Found in: 211204-022539
2021-12-04T022539+0100_RT06_000_TC1.dat
Files Found in: 211204-022844
2021-12-04T022844+0100_RT06_000_TC1.dat
Files Found in: 211204-023148
2021-12-04T023148+0100_RT06_000_TC1.dat
How do I collect these files into one structure that I can loop through?

Accepted Answer

Stephen23
Stephen23 on 27 Jan 2022
Edited: Stephen23 on 27 Jan 2022
The MATLAB approach:
P = 'C:\Users\dbhadra\Desktop\MSD\Sensor Mixing\Pr14 Ryan Data\TC2\RT\Closed_Loop';
S = dir(fullfile(P,'**','*RT06*.dat'))
S will be a structure of filenames and other file information.
In general you should avoid command sytnax like you used, and prefer using function syntax like I showed:

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!