Last active
September 2, 2023 12:44
-
-
Save bukowa/f5c70955c9c2a427db3644b2f7409000 to your computer and use it in GitHub Desktop.
mt4 sync copy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
from pathlib import Path | |
MT4_DIR = Path("C:\\Users\\buk\\AppData\\Roaming\\MetaQuotes\\Terminal\\") | |
MT4_MASTER = MT4_DIR / '2C68BEE3A904BDCEE3EEF5A5A77EC162' | |
BACKUP_DIR = MT4_DIR / 'backup' | |
CACHE_FILE = 'mqlcache.dat' | |
MT4_SLAVES = [ | |
MT4_DIR / 'E014E927B1217F5A561E0813A1C319F3' | |
] | |
COPY_DIRS = [ | |
'templates', | |
'MQL4/Experts', | |
'MQL4/Files', | |
'MQL4/Include', | |
'MQL4/Indicators', | |
'MQL4/Libraries', | |
'MQL4/Presets', | |
'MQL4/Scripts', | |
] | |
def force_cp(cf, ct): | |
try: | |
shutil.rmtree(ct) | |
except FileNotFoundError: | |
pass | |
shutil.copytree(cf, ct) | |
if __name__ == '__main__': | |
for subdir in COPY_DIRS: | |
cfrom = MT4_MASTER / subdir | |
force_cp(cfrom, BACKUP_DIR/subdir) | |
for slave in MT4_SLAVES: | |
cto = slave / subdir | |
print(cfrom) | |
print(cto) | |
force_cp(cfrom, cto) | |
try: | |
os.remove(cto / CACHE_FILE) | |
except FileNotFoundError: | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment