Adding folders now follows Windows ordering
As per issue #11. Was causing problems adding folders numbered 1...999 rather than 001...999.
This commit is contained in:
parent
a71ff52e22
commit
90ab946498
@ -24,6 +24,15 @@ from options import DialogOptions
|
||||
from convert import DialogConvert
|
||||
|
||||
|
||||
import re
|
||||
digits = re.compile(r'(\d+)')
|
||||
def tokenize(filename):
|
||||
return tuple(int(token) if match else token
|
||||
for token, match in
|
||||
((fragment, digits.search(fragment))
|
||||
for fragment in digits.split(filename)))
|
||||
|
||||
|
||||
class Book(object):
|
||||
DefaultDevice = 'Kindle 4'
|
||||
DefaultOutputFormat = 'Images & CBZ'
|
||||
@ -369,12 +378,15 @@ class MainWindowBook(QtGui.QMainWindow):
|
||||
filenames = []
|
||||
|
||||
for directory in directories:
|
||||
for root, subdirs, subfiles in os.walk(unicode(directory)):
|
||||
for filename in subfiles:
|
||||
path = os.path.join(root, filename)
|
||||
if self.isImageFile(path):
|
||||
filenames.append(path)
|
||||
|
||||
directory = unicode(directory)
|
||||
for item in sorted(os.listdir(directory), key=tokenize):
|
||||
item = unicode(item)
|
||||
path = os.path.join(directory, item)
|
||||
if self.isImageFile(path):
|
||||
filenames.append(path)
|
||||
elif os.path.isdir:
|
||||
self.addImageDirs([path])
|
||||
|
||||
self.addImageFiles(filenames)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user