dotfiles/config/nix/scripts/syncthingRestore
Geoffrey Frogeye 1f61ceb395
nix: Migrate scripts
They're a bit slower to start :(.
Hopefully this is something that flakes will help with,
otherwise I'll find another way.
2023-11-26 21:04:58 +01:00

22 lines
542 B
Plaintext
Executable file

#!/usr/bin/env nix-shell
#! nix-shell -i python3 --pure
#! nix-shell -p python3
import os
import shutil
curDir = os.path.realpath(".")
assert ".stversions/" in curDir
tgDir = curDir.replace(".stversions/", "")
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)