-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlalala.py
More file actions
48 lines (45 loc) · 1.68 KB
/
Copy pathlalala.py
File metadata and controls
48 lines (45 loc) · 1.68 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
print ("BANANY Console Ver 0.1")
import os
import shutil
import datetime
def copytree (src, dst, symlinks=False, ignore=None):
# print ("using 2nd library")
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
penghitung = 65
temp = chr(penghitung)
#namafile=....
asal = "/media/pi/6461-6131/DCIM" #yep ini targetnya , kita harus segera adaptasi var. asal
print("backup target: "+asal)
tempat = "/media/pi/Narendra/BANANY_%s" % datetime.datetime.now().date() + temp
while os.path.exists(tempat):
#os.makedirs(tempat)
penghitung = penghitung + 4
temp = chr(penghitung)
tempat = "/media/pi/Narendra/BANANY_%s" % datetime.datetime.now().date() + temp
#while os.path.exists(asal+"/"+namafile): manual way
#yang dibawah tab dulu kalo mau dipake sm while nya
#os.makedirs(tempat)
print(tempat+" setted as destination")
print ("Copying...")
try:
shutil.copytree(asal, tempat)
except shutil.Error as e:
print("Error: %s" % e)
print("backup failed and canceled")
except IOError as e:
print ("Error: %s" % e.strerror)
print ("backup failed and canceled")
print ("process from "+asal+" to "+tempat+" complete")
#target = tempat+"/"+namafile
#os.rename(asal+"/"+namafile, target)
#namafile=#update
#lowvolt speed 1.893MBps
#lowvolt Optimized: 3.1976744MBps, udah 2x test same result
#cek da name, kesalahan terletak pada corrupted file, bila sebuah transfer gagal dengan nama yang sama...
#maka untuk transfer selanjutnya yang pake nama tsb akan error dengan errno 5