Merge pull request #8 from gadse/master
file sorting: Accomodate files without a suffix
This commit is contained in:
commit
951dd1a28b
10
recovery.py
10
recovery.py
|
@ -102,14 +102,20 @@ for root, dirs, files in os.walk(source, topdown=False):
|
||||||
extension = os.path.splitext(file)[1][1:].upper()
|
extension = os.path.splitext(file)[1][1:].upper()
|
||||||
sourcePath = os.path.join(root, file)
|
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):
|
if not os.path.exists(destinationDirectory):
|
||||||
os.mkdir(destinationDirectory)
|
os.mkdir(destinationDirectory)
|
||||||
if keepFilename:
|
if keepFilename:
|
||||||
fileName = file
|
fileName = file
|
||||||
else:
|
else:
|
||||||
fileName = str(fileCounter) + "." + extension.lower()
|
if extension:
|
||||||
|
fileName = str(fileCounter) + "." + extension.lower()
|
||||||
|
else:
|
||||||
|
fileName = str(fileCounter)
|
||||||
|
|
||||||
destinationFile = os.path.join(destinationDirectory, fileName)
|
destinationFile = os.path.join(destinationDirectory, fileName)
|
||||||
if not os.path.exists(destinationFile):
|
if not os.path.exists(destinationFile):
|
||||||
|
|
Loading…
Reference in New Issue