Beispiel #1
0
        extension = os.path.splitext(file)[1][1:].upper()
        sourcePath = os.path.join(root, file)

        destinationDirectory = os.path.join(destination, extension)

        if not os.path.exists(destinationDirectory):
            os.mkdir(destinationDirectory)
        if keepFilename:
            fileName = file
        else:
            fileName = str(fileCounter) + "." + extension.lower()

        destinationFile = os.path.join(destinationDirectory, fileName)
        if not os.path.exists(destinationFile):
            if moveFile is True:
                shutil.move(sourcePath, destinationDirectory)
            else:
                shutil.copy2(sourcePath, destinationFile)

        fileCounter += 1
        if ((fileCounter % onePercentFiles) is 0):
            log(str(fileCounter) + " / " + totalAmountToCopy + " processed.")

log("start special file treatment")
jpgSorter.postprocessImages(os.path.join(destination, "JPG"),
                            minEventDeltaDays, splitMonths)

log("assure max file per folder number")
numberOfFilesPerFolderLimiter.limitFilesPerFolder(destination,
                                                  maxNumberOfFilesPerFolder)
totalAmountToCopy = str(fileNumber)
print("Files to copy: " + totalAmountToCopy)


fileCounter = 0
for root, dirs, files in os.walk(source, topdown=False):

	for file in files:
		extension = os.path.splitext(file)[1][1:].upper()
		sourcePath = os.path.join(root, file)
		
		destinationDirectory = os.path.join(destination, extension)

		if not os.path.exists(destinationDirectory):
			os.mkdir(destinationDirectory)
		
		fileName = str(fileCounter) + "." + extension.lower()
		destinationFile = os.path.join(destinationDirectory, fileName)
		if not os.path.exists(destinationFile):
			shutil.copy2(sourcePath, destinationFile)

		fileCounter += 1
		if((fileCounter % onePercentFiles) is 0):
			log(str(fileCounter) + " / " + totalAmountToCopy + " processed.")

log("start special file treatment")
jpgSorter.postprocessImages(os.path.join(destination, "JPG"))

log("assure max file per folder number")
numberOfFilesPerFolderLimiter.limitFilesPerFolder(destination, maxNumberOfFilesPerFolder)