Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 94de120

Browse files
Update pdfmerge.py
1 parent 93e1712 commit 94de120

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pdfmerge.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
def pdf_concat():
1212
pdfs = []
1313

14-
file_path = filedialog.askdirectory()
15-
destination = file_path + os.path.sep + 'merged'
14+
filePath = filedialog.askdirectory()
15+
destination = filePath + os.path.sep + 'merged'
1616

17-
# load all "".pdf" files from the selected directory
17+
# load all ".pdf" files from the selected directory
1818
# and put them into a list
19-
for file in os.listdir(file_path):
19+
for file in os.listdir(filePath):
2020
if file.endswith(".pdf"):
21-
pdfs.append(os.path.join(file_path, file))
21+
pdfs.append(os.path.join(filePath, file))
2222

2323
pdfs.sort()
2424
pdfLen = len(pdfs)
2525

26-
print(f'Found {pdfLen} ".pdf files" in {file_path}')
26+
print(f'Found {pdfLen} ".pdf" files in {filePath}')
2727

2828
# return if directory was empty
2929
if (pdfLen < 1):
@@ -42,7 +42,7 @@ def pdf_concat():
4242
length = int(len(pdfs) / 2) + 1
4343
x = 1
4444

45-
# chunk the list into chunks of 2 and merge them
45+
# chunk the list into chunks of two and merge them
4646
for i in chunks(pdfs, 2):
4747
newFilename = f'{destination}{os.path.sep}{uuid.uuid4()}.pdf'
4848

@@ -56,13 +56,14 @@ def pdf_concat():
5656

5757
# give the user progress feedback
5858
progress = int((x / length) * 100)
59-
print(f'{newFilename} ({x} von {length}) {progress}%')
59+
print(f'{newFilename} ({x} of {length}) {progress}%')
6060

6161
x += 1
6262

6363
# prevent automatic closing of the process
6464
input()
6565

66+
6667
### php: array_chunk
6768
def chunks(lst, n):
6869
for i in range(0, len(lst), n):

0 commit comments

Comments
 (0)