-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (63 loc) · 2.36 KB
/
Copy pathmain.py
File metadata and controls
66 lines (63 loc) · 2.36 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
##THIS FILE ONLY RUN PYTHON 3
import glob
import os.path
from pathlib import Path
import re
def concat(basefile):#no modificar esta parte del codigo a menos que estes seguro....
if Path(basefile+"/complete.bin").exists():
print("ERROR CAMBIA EL NOMBRE A complete.bin para evitar errores")
exit(0)
objetivo = open(basefile+"/complete.bin","wb")
original = []
concatenadores = []
for archivo in glob.glob(basefile+"/*.*"):
target = os.path.basename(archivo)
if target == "complete.bin":
continue
m = re.compile("([0-9]+)\\.tmp")
if m.match(target) :
concatenadores.append(m.search(target).group(1))
else:
original.append(target)
if not concatenadores or not original:
print("VERIFICA EL ARCHIVO ORIGIANL Y LOS TEMPORALES QUE EMPIEZACON CON NUMEROS Y EXTENSION .tmp")
exit(0)
concatenadores.sort(key=int)
tmp = open(basefile+"/"+original[0],"rb")
while True:
buffer = tmp.read(2048)
if not buffer:
break
objetivo.write(buffer)
objetivo.flush()
tmp.close()
os.remove(basefile+"/"+original[0])
print("REMOVIENDO EL ARCHIVO PRINCIPAL ANIDAD AL OTRO")
for temporal in concatenadores:
tmp = open(basefile+"/"+temporal+".tmp","rb")
while True:
buffer = tmp.read(2048)
if not buffer:
break
objetivo.write(buffer)
objetivo.flush()
tmp.close()
os.remove(basefile+"/"+temporal+".tmp")
print("EL ARCHIVO "+temporal+".tmp A SIDO GUARDADO AL OBJETIVO Y BORRADO ESPERA TERMINANDO")
objetivo.close()
print("SE TERMINO EL PROCESO EL ARCHIVO A SIDO UNIDO")
print("///////ESCRIPT DESARROLLADO POR WILLIAM THOMSON 2018\\\\\\\\")
print("---------* ESCOGE QUE HACER *-------------")
print("[1] Obtener el tamaño en bytes del archivo ")
print("[2] Concatenar archivos segun el directorio")
seleccion = input("CUAL ELIGes: ")
if seleccion == "1":
archivo = input("PEGA AQUI LA RUTA DEL ARCHIVO CON EL ARCHIVO EJEMPLO: /sdcard/example.iso: ")
print(os.path.getsize(archivo))
input("PRESION ENTER PARA SALIR")
exit(0)
if seleccion == "2":
archivo = input("PEGA EL DIRECTORIO DONDE SE ENCUENTRE EL ARCHIVO Y LOS ARCHIVOS TEMPORALES ej: /sdcard/archivos: ")
concat(archivo)
else:
print("ERRO")