forked from Tfloow/Q4_EPL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sorting.py
27 lines (23 loc) · 901 Bytes
/
Sorting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import shutil
def onlyPDF(elemList):
"""
:param elemList: a List of element in a directory
:return: only the pdf Document
"""
good = []
for elem in elemList:
if(elem.split(".")[-1].lower() == "pdf"):
good.append(elem)
return good
def run():
folderList = ["Elec", "FYKI", "GBio", "GC", "Info", "MAP", "Méca", "TroncCommun"] # name of different folder
target = "..\\SynthèseCompilée" # were to put the pdf
syntheseFolder = "..\\Synthèse" # from where they should be
for i in os.walk(syntheseFolder): # going through all the folder and files of the Synthèse folder
if len(onlyPDF(i[-1])) > 0:
for pdf in onlyPDF(i[-1]):
shutil.copy(i[0] + "\\" + pdf, target + "\\" + pdf) # copying the pdf to the target folder
print("Synthèse(s) copiée(s)")
if __name__ == "__main__":
run()