file sorting: Accomodate files without a suffix

This commit is contained in:
Peter Bozsoky 2022-04-12 16:22:05 +02:00
parent f59c7bf8cd
commit 4bf4057cff
1 changed files with 8 additions and 2 deletions

View File

@ -102,14 +102,20 @@ for root, dirs, files in os.walk(source, topdown=False):
extension = os.path.splitext(file)[1][1:].upper()
sourcePath = os.path.join(root, file)
destinationDirectory = os.path.join(destination, extension)
if extension:
destinationDirectory = os.path.join(destination, extension)
else:
destinationDirectory = os.path.join(destination, "_NO_EXTENSION")
if not os.path.exists(destinationDirectory):
os.mkdir(destinationDirectory)
if keepFilename:
fileName = file
else:
fileName = str(fileCounter) + "." + extension.lower()
if extension:
fileName = str(fileCounter) + "." + extension.lower()
else:
fileName = str(fileCounter)
destinationFile = os.path.join(destinationDirectory, fileName)
if not os.path.exists(destinationFile):