forked from yocson/HandWritingDataSet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriter_folder.py
More file actions
34 lines (20 loc) · 739 Bytes
/
Copy pathwriter_folder.py
File metadata and controls
34 lines (20 loc) · 739 Bytes
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
28
29
30
31
32
33
34
import os
import glob
import shutil
forms_for_parsing=open(r'forms_for_parsing.txt',mode='r')
d = {}
lines=forms_for_parsing.readlines()
for line in lines:
key = line.split(' ')[0]
writer = line.split(' ')[1]
d[key] = writer
if not os.path.exists(writer):
os.makedirs(writer)
# print(d)
outputDir = os.getcwd()
for fpath in glob.glob('*.png'): # this returns a list of the CURRENT contents. Therefore, there is no need to sanitize for the directories that we will later create
filekey="-".join(fpath.split("-", 2)[:2])
filewriter=d[filekey]
print(filewriter)
print(os.path.join(outputDir, filewriter))
shutil.move(fpath, os.path.join(outputDir, filewriter))