-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge.py
More file actions
30 lines (24 loc) · 774 Bytes
/
Copy pathmerge.py
File metadata and controls
30 lines (24 loc) · 774 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
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 25 15:53:11 2016
@author: nazario
This file merges files in a directory to another
"""
import os
import shutil
work_dir = '/media/nazario/SAMSUNG/COSMIC'
sr_dir='cosmic2013 (4)'
ds_dir='cosmic2013 (3)'
root_src_dir = os.path.join(work_dir,sr_dir)
root_dst_dir = os.path.join(work_dir,ds_dir)
print(root_src_dir)
for src_dir, dirs, files in os.walk(root_src_dir):
dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1)
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
for file_ in files:
src_file = os.path.join(src_dir, file_)
dst_file = os.path.join(dst_dir, file_)
if os.path.exists(dst_file):
os.remove(dst_file)
shutil.move(src_file, dst_dir)