Im reading in some files from a directory using glob.glob, these files are named as such: 1.bmp
The files/names continue in this naming pattern: 1.bmp, 2.bmp, 3.bmp ... and so on
This is the code that i currently have, however whilst technically this does sort, it isnt as expected.
files= sorted(glob.glob('../../Documents/ImageAnalysis.nosync/sliceImage/*.bmp'))
This method sorts as such:
../../Documents/ImageAnalysis.nosync/sliceImage/84.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/85.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/86.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/87.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/88.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/89.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/9.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/90.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/91.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/92.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/93.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/94.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/95.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/96.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/97.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/98.bmp
../../Documents/ImageAnalysis.nosync/sliceImage/99.bmp
In the above code i have highlighted the problem really, it is able to sort the file names well for e.g 90-99.bmp is completely fine however between 89.bmp and 90.bmp there is the file 9.bmp this obviously shouldnt be there and should be near the start
The sort of output that im expecting is like this:
1.bmp
2.bmp
3.bmp
4.bmp
5.bmp
6.bmp
...
10.bmp
11.bmp
12.bmp
13.bmp
...
and so on until the end of the files
Is this possible to do with glob?