Merge pull request #8 from gadse/master

file sorting: Accomodate files without a suffix
This commit is contained in:
Lukas Hahmann 2022-08-20 18:17:17 +02:00 committed by GitHub
commit 951dd1a28b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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):