66 lines
No EOL
1.8 KiB
Python
66 lines
No EOL
1.8 KiB
Python
import os
|
|
import sys
|
|
import shutil
|
|
|
|
def get_source_path_and_validate():
|
|
print("Searching for source folder")
|
|
attempts = 100
|
|
while attempts >= 0:
|
|
path = input("Enter the path of the source folder: ")
|
|
|
|
if not os.path.exists(path):
|
|
print("Folder does not exist: ", path)
|
|
|
|
if attempts == 1:
|
|
print("Maximum attempts exceeded")
|
|
return False, None
|
|
else:
|
|
print("Selected path: ", path)
|
|
return True, path
|
|
|
|
""" Decrement """
|
|
attempts -= 1
|
|
|
|
def get_destination_path_and_validate():
|
|
print("Searching for destination folder")
|
|
attempts = 100
|
|
while attempts >= 0:
|
|
destination_path = input("Enter the path of your MQL5\\Include: ")
|
|
|
|
""" Validate existence """
|
|
if not os.path.exists(destination_path):
|
|
print("Entered path: ", destination_path, " does not exist")
|
|
|
|
if attempts == 1:
|
|
print("Maximum attempts exceeded")
|
|
return False, None
|
|
|
|
else:
|
|
print("Selected file: ", destination_path)
|
|
return True, destination_path
|
|
|
|
""" Decrement """
|
|
attempts -= 1
|
|
|
|
|
|
res, path1 = get_source_path_and_validate()
|
|
if not res:
|
|
sys.exit()
|
|
|
|
|
|
res, path2 = get_destination_path_and_validate()
|
|
if not res:
|
|
sys.exit()
|
|
|
|
|
|
for item in os.listdir(path1):
|
|
complete_path = os.path.join(path1, item, "Include")
|
|
if os.path.exists(complete_path):
|
|
if os.path.isdir(complete_path):
|
|
print(f"Folder found: {item}")
|
|
print(f"Path: {complete_path}")
|
|
|
|
try:
|
|
shutil.copytree(complete_path, path2, dirs_exist_ok=True)
|
|
except Exception as e:
|
|
print(f"Error copying {item}: {e}") |