Filter löschen
Filter löschen

Read all files of a directory in a "human-way" order

5 Ansichten (letzte 30 Tage)
Alan Meier
Alan Meier am 18 Jun. 2020
Beantwortet: KSSV am 18 Jun. 2020
I'm trying to read all .png files of my current working directory on Windows. Therefor I tried approch 1 described in the wiki: https://matlab.fandom.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
My code is the following:
filePattern = fullfile(pwd, '*.png');
filename_structure = dir(filePattern);
While this works fine the resulting names are not in the desired order. The current order is:
pic1.png
pic10.png
pic100.png
pic1000.png
pic1001.png
I would like to have the names sorted the "human/logical way":
pic1.png
pic2.png
pic3.png
Is it possible to set a option for that while reading the file names?

Akzeptierte Antwort

KSSV
KSSV am 18 Jun. 2020

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