How open a folder without the files beginning with '.'

3 Ansichten (letzte 30 Tage)
Elise C
Elise C am 25 Apr. 2022
Kommentiert: Mathieu NOE am 26 Apr. 2022
Hi! I want to open all the file of my folder 'calibration_data' (cf Fig1).
But when I do my code (cf Code1), it open 3 files that are'nt in my folder (cf '.', '..' and '.DS_Store' in Fig2).
What are they and how can I get rid of them?
Thanks!
---
Fig1:
Fig2:
Code1:
path_root = '/Users/TP4/calibration_data';
files=dir(fullfile(path_root));
  2 Kommentare
Mathieu NOE
Mathieu NOE am 25 Apr. 2022
hello
see my suggestion below but change the extension (raw) according to your files
S = dir('**/*.raw');
[m,n] = size(S);
for ci = 1:m
folders{ci} = S(ci).folder;
filenames{ci} = S(ci).name;
end
Mathieu NOE
Mathieu NOE am 25 Apr. 2022
if you have all your files starting with "tempo"
you can also try with :
S = dir('TEMPO*.*');

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephen23
Stephen23 am 25 Apr. 2022
Bearbeitet: Stephen23 am 25 Apr. 2022
"What are they..."
  • dot directory names, where '.' represents the directory itself and '..' its immediate parent.
  • .DS_Store is a hidden file used by MacOS to store information about how a folder is displayed.
"... how can I get rid of them?"
By not having them in the first place. You can do that by simply specifying the DIR search string to match the filenames (including wildcards as required), e.g.:
P = '/Users/TP4/calibration_data';
S = dir(fullfile(P,'TEMPOL*'));
  2 Kommentare
Elise C
Elise C am 26 Apr. 2022
Thank you Stephen!
And also thanks to Mathieu :)
Mathieu NOE
Mathieu NOE am 26 Apr. 2022
My pleasure !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by