Skip to content

Commit dc9b462

Browse files
committed
Make indentation style consistent (all spaces now).
1 parent a1266c6 commit dc9b462

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

Diff for: numberOfFilesPerFolderLimiter.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55

66

77
def limitFilesPerFolder(folder, maxNumberOfFilesPerFolder):
8-
for root, dirs, files in os.walk(folder, topdown=False):
9-
for dir in dirs:
10-
dirPath = os.path.join(root, dir)
11-
filesInFolder = len(os.listdir(dirPath))
12-
if(filesInFolder > maxNumberOfFilesPerFolder):
13-
numberOfSubfolders = ((filesInFolder - 1) // maxNumberOfFilesPerFolder) + 1
14-
for subFolderNumber in range(1, numberOfSubfolders+1):
15-
subFolderPath = os.path.join(dirPath, str(subFolderNumber))
16-
if not os.path.exists(subFolderPath):
17-
os.mkdir(subFolderPath)
18-
fileCounter = 1
19-
for file in os.listdir(dirPath):
20-
source = os.path.join(dirPath, file)
21-
if os.path.isfile(source):
22-
destDir = str(((fileCounter - 1) // maxNumberOfFilesPerFolder) + 1)
23-
destination = os.path.join(dirPath, destDir, file)
24-
shutil.move(source, destination)
25-
fileCounter += 1
8+
for root, dirs, files in os.walk(folder, topdown=False):
9+
for dir in dirs:
10+
dirPath = os.path.join(root, dir)
11+
filesInFolder = len(os.listdir(dirPath))
12+
if(filesInFolder > maxNumberOfFilesPerFolder):
13+
numberOfSubfolders = ((filesInFolder - 1) // maxNumberOfFilesPerFolder) + 1
14+
for subFolderNumber in range(1, numberOfSubfolders+1):
15+
subFolderPath = os.path.join(dirPath, str(subFolderNumber))
16+
if not os.path.exists(subFolderPath):
17+
os.mkdir(subFolderPath)
18+
fileCounter = 1
19+
for file in os.listdir(dirPath):
20+
source = os.path.join(dirPath, file)
21+
if os.path.isfile(source):
22+
destDir = str(((fileCounter - 1) // maxNumberOfFilesPerFolder) + 1)
23+
destination = os.path.join(dirPath, destDir, file)
24+
shutil.move(source, destination)
25+
fileCounter += 1
2626

2727

Diff for: recovery.py

+33-33
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ def getNumberOfFilesInFolderRecursively(start_path = '.'):
1515
for f in filenames:
1616
fp = os.path.join(dirpath, f)
1717
if(os.path.isfile(fp)):
18-
numberOfFiles += 1
18+
numberOfFiles += 1
1919
return numberOfFiles
2020

2121

2222
def getNumberOfFilesInFolder(path):
23-
return len(os.listdir(path))
23+
return len(os.listdir(path))
2424

2525

2626
def log(logString):
27-
print(strftime("%H:%M:%S", localtime()) + ": " + logString)
27+
print(strftime("%H:%M:%S", localtime()) + ": " + logString)
2828

2929

3030
def moveFile(file, destination):
31-
extension = os.path.splitext(file)[1][1:].upper()
32-
sourcePath = os.path.join(root, file)
31+
extension = os.path.splitext(file)[1][1:].upper()
32+
sourcePath = os.path.join(root, file)
3333

34-
destinationDirectory = os.path.join(destination, extension)
34+
destinationDirectory = os.path.join(destination, extension)
3535

36-
if not os.path.exists(destinationDirectory):
37-
os.mkdir(destinationDirectory)
36+
if not os.path.exists(destinationDirectory):
37+
os.mkdir(destinationDirectory)
3838

39-
fileName = str(fileCounter) + "." + extension.lower()
40-
destinationFile = os.path.join(destinationDirectory, fileName)
41-
if not os.path.exists(destinationFile):
42-
shutil.copy(sourcePath, destinationFile)
39+
fileName = str(fileCounter) + "." + extension.lower()
40+
destinationFile = os.path.join(destinationDirectory, fileName)
41+
if not os.path.exists(destinationFile):
42+
shutil.copy(sourcePath, destinationFile)
4343

4444

4545

@@ -48,20 +48,20 @@ def moveFile(file, destination):
4848
destination = None
4949

5050
if(len(sys.argv) < 3):
51-
print("Enter source and destination: python sort.py source/path destination/path")
51+
print("Enter source and destination: python sort.py source/path destination/path")
5252
else:
53-
source = sys.argv[1]
54-
print("Source directory: " + source)
55-
destination = sys.argv[2]
56-
print("Destination directory: " + destination)
53+
source = sys.argv[1]
54+
print("Source directory: " + source)
55+
destination = sys.argv[2]
56+
print("Destination directory: " + destination)
5757

5858
if(len(sys.argv) > 3):
59-
maxNumberOfFilesPerFolder = int(sys.argv[3])
59+
maxNumberOfFilesPerFolder = int(sys.argv[3])
6060

6161
while ((source is None) or (not os.path.exists(source))):
62-
source = input('Enter a valid source directory\n')
62+
source = input('Enter a valid source directory\n')
6363
while ((destination is None) or (not os.path.exists(destination))):
64-
destination = input('Enter a valid destination directory\n')
64+
destination = input('Enter a valid destination directory\n')
6565

6666
fileNumber = getNumberOfFilesInFolderRecursively(source)
6767
onePercentFiles = int(fileNumber/100)
@@ -72,23 +72,23 @@ def moveFile(file, destination):
7272
fileCounter = 0
7373
for root, dirs, files in os.walk(source, topdown=False):
7474

75-
for file in files:
76-
extension = os.path.splitext(file)[1][1:].upper()
77-
sourcePath = os.path.join(root, file)
75+
for file in files:
76+
extension = os.path.splitext(file)[1][1:].upper()
77+
sourcePath = os.path.join(root, file)
7878

79-
destinationDirectory = os.path.join(destination, extension)
79+
destinationDirectory = os.path.join(destination, extension)
8080

81-
if not os.path.exists(destinationDirectory):
82-
os.mkdir(destinationDirectory)
81+
if not os.path.exists(destinationDirectory):
82+
os.mkdir(destinationDirectory)
8383

84-
fileName = str(fileCounter) + "." + extension.lower()
85-
destinationFile = os.path.join(destinationDirectory, fileName)
86-
if not os.path.exists(destinationFile):
87-
shutil.copy2(sourcePath, destinationFile)
84+
fileName = str(fileCounter) + "." + extension.lower()
85+
destinationFile = os.path.join(destinationDirectory, fileName)
86+
if not os.path.exists(destinationFile):
87+
shutil.copy2(sourcePath, destinationFile)
8888

89-
fileCounter += 1
90-
if((fileCounter % onePercentFiles) is 0):
91-
log(str(fileCounter) + " / " + totalAmountToCopy + " processed.")
89+
fileCounter += 1
90+
if((fileCounter % onePercentFiles) is 0):
91+
log(str(fileCounter) + " / " + totalAmountToCopy + " processed.")
9292

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

0 commit comments

Comments
 (0)