Need an Elegant Sorting Solution for Directory File Names
Ältere Kommentare anzeigen
I have a directory of filenames, (within a files structure array) structured like this:
cdef2.20140101.pdef.txt
cdef2.20140102.pdef.txt
....
pdef.gdef.201300101-20130105.txt
pdef.gdef.201300106-20130110.txt
....
I need to reorder these (ascending order from oldest to newest) according to the dates embedded within these file names which are formatted like YYYYMMDD. I've explored several options, but I'm seeking an elegant solution without do loops. Any tips or suggestions would be appreciated.
3 Kommentare
Sandeep Mishra
am 9 Jul. 2023
Which date to consider in file names like pdef.gdef.201300101-20130105.txt ?
The file naming also doesn't contain any special pattern to avoid loop,
If you can change cdef2.20140101.pdef.txt to cdef2.pdef.20140101.txt, then it will be easier to split all files names using delimiter ('.')
John Cruce
am 9 Jul. 2023
Sandeep Mishra
am 9 Jul. 2023
Can we assume that there exist only two type of files?
One which starts with cdef2 and one which starts with pdef?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu File Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!