Sorting files with alphanumeric names in a structure array
Mostrar comentarios más antiguos
Hi!
I'm trying to sort the text files of my struct array. The files are called:
Report (1).txt
Report (2).txt
.
.
.
Report (10).txt
Report (11).txt
.
.
.
Report (34).txt
What I want is something like:
Report (1).txt
Report (2).txt
Report (3).txt
Report (4).txt
.
.
.
Report (10).txt
But if I read directly without trying to sort them, this is the order in which they are read:
Report (1).txt
Report (10).txt
Report (11).txt
.
.
.
Report (2).txt
Report (20).txt
The amount of reports could be up to hundreds.
So, what I did to sort them is in the attached file.
However, for some reason it doesn't work properly and this is the output:
Report (1).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (2).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (3).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (4).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (5).TXT
Report (6).TXT
Report (6).TXT
Report (6).TXT
Report (6).TXT
Report (6).TXT
Report (6).TXT
Report (7).TXT
Report (8).TXT
Report (9).TXT
I'm getting crazy with this. I really don't find what I'm doing wrong. Could some of you please help me in this?
Respuestas (1)
Walter Roberson
el 15 de Nov. de 2016
0 votos
Look in the File Exchange; there are a couple of routines such as Natural Sort Filename, or Natural Sort
1 comentario
LETICIA RUIZ
el 15 de Nov. de 2016
Categorías
Más información sobre Structured Data and XML Documents en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!