dotfiles/config/scripts/rmf

24 lines
563 B
Plaintext
Raw Normal View History

2018-11-24 13:45:14 +01:00
#!/usr/bin/env python3
# Rename sync-conflict files to normal files
# WARNING Does not check for conclicts
import os
import re
for root, dirs, files in os.walk('.'):
for f in files:
if '.sync-conflict' not in f:
continue
nf = re.sub('.sync-conflict-\d{8}-\d{6}-\w{7}', '', f)
F = os.path.join(root, f)
NF = os.path.join(root, nf)
if os.path.exists(NF):
print(f"'{F}' → '{NF}': file already exists")
else:
print(f"'{F}' → '{NF}': done")
os.rename(F, NF)