From 4bf4057cff67e0d9306a649ca6996353ba4ccfc7 Mon Sep 17 00:00:00 2001 From: Peter Bozsoky Date: Tue, 12 Apr 2022 16:22:05 +0200 Subject: [PATCH] file sorting: Accomodate files without a suffix --- recovery.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/recovery.py b/recovery.py index 459e663..d83a4d8 100755 --- a/recovery.py +++ b/recovery.py @@ -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):