-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove.py
More file actions
22 lines (21 loc) · 732 Bytes
/
move.py
File metadata and controls
22 lines (21 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import shutil
lines = [line.strip() for line in open('./train.txt')]
for line in lines:
filename = line.split("/")[-1]
filename = filename.split()[0]
print filename
line = line.split()[0]
dest = '/Users/alaruba/CS231/Pictures/images/train/' +filename
with open(line, 'rb') as fsrc:
with open(dest, 'wb') as fdest:
shutil.copyfileobj(fsrc, fdest)
dest = '/Users/alaruba/CS231/Pictures/images/val/'
lines = [line.strip() for line in open('./test.txt')]
for line in lines:
filename = line.split("/")[-1]
filename = filename.split()[0]
line = line.split()[0]
dest = '/Users/alaruba/CS231/Pictures/images/val/' +filename
with open(line, 'rb') as fsrc:
with open(dest, 'wb') as fdest:
shutil.copyfileobj(fsrc, fdest)