dotfiles/config/scripts/syncthingRestore

20 lines
485 B
Plaintext
Raw Normal View History

2018-10-18 19:14:11 +00:00
#!/usr/bin/env python3
import os
import shutil
2021-06-13 09:49:21 +00:00
curDir = os.path.realpath(".")
assert ".stversions/" in curDir
tgDir = curDir.replace(".stversions/", "")
2018-10-18 19:14:11 +00:00
for root, dirs, files in os.walk(curDir):
dstRoot = root.replace(curDir, tgDir)
os.makedirs(dstRoot, exist_ok=True)
for f in files:
srcPath = os.path.join(root, f)
dstF = f
dstPath = os.path.join(dstRoot, dstF)
print(f"{srcPath} → {dstPath}")
shutil.copy2(srcPath, dstPath)