Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sort list of files by name python

import os
import numpy as np

myimages = [] #list of image filenames
dirFiles = os.listdir('.') #list of directory files
dirFiles.sort() #good initial sort but doesnt sort numerically very well
sorted(dirFiles) #sort numerically in ascending order

for files in dirFiles: #filter out all non jpgs
    if '.jpg' in files:
        myimages.append(files)
print len(myimages)
print myimages
 
PREVIOUS NEXT
Tagged: #sort #list #files #python
ADD COMMENT
Topic
Name
6+4 =