Mercurial > hg > ocrHandling
comparison copyFiles.py @ 0:5e33fa5a2fdc
initial
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 19 Aug 2014 14:12:52 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5e33fa5a2fdc |
---|---|
1 from _csv import Error | |
2 start ="/Volumes/Folivora/MPG_Archiv/" | |
3 target = "/Volumes/MPGARCHIV/input/" | |
4 | |
5 | |
6 import os | |
7 import shutil | |
8 | |
9 errorf = open("/tmp/error.out","w",encoding="utf-8") | |
10 errorf.write("START") | |
11 | |
12 for root, dirs, files in os.walk(start, topdown=False): | |
13 for name in files: | |
14 path = os.path.join(root, name) | |
15 ext = os.path.splitext(path) | |
16 print (name) | |
17 if ext[1] == ".pdf": | |
18 | |
19 fld = os.path.split(root) | |
20 print (fld) | |
21 neu = os.path.join(target,fld[1]+"___"+name.replace(" ","_")) | |
22 if not os.path.exists(neu): | |
23 try: | |
24 shutil.copy(path, neu) | |
25 except: | |
26 errorf.write(path+"\n") | |
27 print (path) | |
28 else: | |
29 print("EXISTS:" + path) | |
30 | |
31 errorf.close(); | |
32 | |
33 | |
34 | |
35 #for name in dirs: | |
36 # print(os.path.join(root, name)) | |
37 | |
38 |