Cleanup whitespace.
This commit is contained in:
parent
db3970d4a5
commit
a1266c6aa2
|
@ -18,7 +18,7 @@ def getMinimumCreationTime(exif_data):
|
||||||
if (dateTimeOriginal is None):
|
if (dateTimeOriginal is None):
|
||||||
# case 1/9: dateTime, dateTimeOriginal, and dateTimeDigitized = None
|
# case 1/9: dateTime, dateTimeOriginal, and dateTimeDigitized = None
|
||||||
# case 2/9: dateTime and dateTimeOriginal = None, then use dateTimeDigitized
|
# case 2/9: dateTime and dateTimeOriginal = None, then use dateTimeDigitized
|
||||||
creationTime = dateTimeDigitized
|
creationTime = dateTimeDigitized
|
||||||
else:
|
else:
|
||||||
# case 3/9: dateTime and dateTimeDigitized = None, then use dateTimeOriginal
|
# case 3/9: dateTime and dateTimeDigitized = None, then use dateTimeOriginal
|
||||||
# case 4/9: dateTime = None, prefere dateTimeOriginal over dateTimeDigitized
|
# case 4/9: dateTime = None, prefere dateTimeOriginal over dateTimeDigitized
|
||||||
|
@ -33,7 +33,7 @@ def postprocessImage(images, imageDirectory, fileName):
|
||||||
imagePath = os.path.join(imageDirectory, fileName)
|
imagePath = os.path.join(imageDirectory, fileName)
|
||||||
image = open(imagePath, 'rb')
|
image = open(imagePath, 'rb')
|
||||||
creationTime = None
|
creationTime = None
|
||||||
try:
|
try:
|
||||||
exifTags = exifread.process_file(image, details=False)
|
exifTags = exifread.process_file(image, details=False)
|
||||||
creationTime = getMinimumCreationTime(exifTags)
|
creationTime = getMinimumCreationTime(exifTags)
|
||||||
except:
|
except:
|
||||||
|
@ -89,7 +89,7 @@ def writeImages(images, destinationRoot, splitByMonth=False):
|
||||||
createUnknownDateFolder(destinationRoot)
|
createUnknownDateFolder(destinationRoot)
|
||||||
destination = os.path.join(destinationRoot, unknownDateFolderName)
|
destination = os.path.join(destinationRoot, unknownDateFolderName)
|
||||||
destinationFilePath = os.path.join(destination, fileName)
|
destinationFilePath = os.path.join(destination, fileName)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if (previousTime == None) or ((previousTime + minEventDelta) < imageTuple[0]):
|
if (previousTime == None) or ((previousTime + minEventDelta) < imageTuple[0]):
|
||||||
eventNumber = eventNumber + 1
|
eventNumber = eventNumber + 1
|
||||||
|
|
|
@ -16,12 +16,12 @@ def limitFilesPerFolder(folder, maxNumberOfFilesPerFolder):
|
||||||
if not os.path.exists(subFolderPath):
|
if not os.path.exists(subFolderPath):
|
||||||
os.mkdir(subFolderPath)
|
os.mkdir(subFolderPath)
|
||||||
fileCounter = 1
|
fileCounter = 1
|
||||||
for file in os.listdir(dirPath):
|
for file in os.listdir(dirPath):
|
||||||
source = os.path.join(dirPath, file)
|
source = os.path.join(dirPath, file)
|
||||||
if os.path.isfile(source):
|
if os.path.isfile(source):
|
||||||
destDir = str(((fileCounter - 1) // maxNumberOfFilesPerFolder) + 1)
|
destDir = str(((fileCounter - 1) // maxNumberOfFilesPerFolder) + 1)
|
||||||
destination = os.path.join(dirPath, destDir, file)
|
destination = os.path.join(dirPath, destDir, file)
|
||||||
shutil.move(source, destination)
|
shutil.move(source, destination)
|
||||||
fileCounter += 1
|
fileCounter += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ def log(logString):
|
||||||
def moveFile(file, destination):
|
def moveFile(file, destination):
|
||||||
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)
|
destinationDirectory = os.path.join(destination, extension)
|
||||||
|
|
||||||
if not os.path.exists(destinationDirectory):
|
if not os.path.exists(destinationDirectory):
|
||||||
os.mkdir(destinationDirectory)
|
os.mkdir(destinationDirectory)
|
||||||
|
|
||||||
fileName = str(fileCounter) + "." + extension.lower()
|
fileName = str(fileCounter) + "." + extension.lower()
|
||||||
destinationFile = os.path.join(destinationDirectory, fileName)
|
destinationFile = os.path.join(destinationDirectory, fileName)
|
||||||
if not os.path.exists(destinationFile):
|
if not os.path.exists(destinationFile):
|
||||||
|
@ -75,12 +75,12 @@ for root, dirs, files in os.walk(source, topdown=False):
|
||||||
for file in files:
|
for file in files:
|
||||||
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)
|
destinationDirectory = os.path.join(destination, extension)
|
||||||
|
|
||||||
if not os.path.exists(destinationDirectory):
|
if not os.path.exists(destinationDirectory):
|
||||||
os.mkdir(destinationDirectory)
|
os.mkdir(destinationDirectory)
|
||||||
|
|
||||||
fileName = str(fileCounter) + "." + extension.lower()
|
fileName = str(fileCounter) + "." + extension.lower()
|
||||||
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