From e2c487edfb88878c8f546b313688552c8b34c7b7 Mon Sep 17 00:00:00 2001 From: TomConlin Date: Sat, 17 Jun 2017 10:12:01 -0700 Subject: [PATCH] sort files to be captioned by filename --- utils/fcaption | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/utils/fcaption b/utils/fcaption index 03294c8..d41d22f 100755 --- a/utils/fcaption +++ b/utils/fcaption @@ -218,14 +218,16 @@ class MainWindow(QtGui.QMainWindow): # main application def expand_dir(path): - for root, dirs, files in os.walk(path): - for tmp in files: - if tmp[0] == '.': continue - tmp = os.path.join(root, tmp) - ext = os.path.splitext(tmp)[1] - if ext: ext = ext[1:].lower() - if ext in FILE_EXT: - yield tmp + for root, dirs, files in os.walk(path, topdown=True): + if files is not None: + files.sort() + for tmp in files: + if tmp[0] == '.': continue + tmp = os.path.join(root, tmp) + ext = os.path.splitext(tmp)[1] + if ext: ext = ext[1:].lower() + if ext in FILE_EXT: + yield tmp class Application(QtGui.QApplication):