forked from KEMMY/BC-2012
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_tree.py
34 lines (29 loc) · 888 Bytes
/
copy_tree.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
28
29
30
31
32
33
34
import os
import sys
from stat import *
import shutil
import sys
sys.path.append('/home/kmm/Plocha/python_code')
import metadata_maker
def walktree(src,trg):
for f in os.listdir(src):
pathname = os.path.join(src, f)
mode = os.stat(pathname).st_mode
print (mode)
if S_ISDIR(mode):
# It's a directory
print "os.mkdir(%s)" % (trg)
dst = os.path.join(trg,f)
os.mkdir(dst)
walktree(pathname,dst)
elif S_ISREG(mode):
print (pathname)
print "shutil.copy(%s,%s)" % (src,trg)
abc = os.path.join(trg,f)
shutil.copy(pathname,abc)
else:
# Unknown file type, print a message
print('Skipping %s' % pathname)
src="/home/kmm/Plocha/source/"
trg="/home/kmm/Plocha/target/zaloha"
walktree(src,trg)