Spaces:
Runtime error
Runtime error
File size: 682 Bytes
cdcee1d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/usr/bin/env python3
import os
# cd checkpoints
# Root folder where your symlinks are located
folder = "."
old_prefix = "/Users/cuongpc/"
new_prefix = "/home/user/"
old_prefix_1 = "../../../../../root/"
for entry in os.listdir(folder):
path = os.path.join(folder, entry)
if os.path.islink(path):
target = os.readlink(path)
if target.startswith(old_prefix) or target.startswith(old_prefix_1):
new_target = target.replace(old_prefix, new_prefix, 1).replace(old_prefix_1, new_prefix, 1)
print(f"Updating: {path}\n {target} -> {new_target}")
os.remove(path) # remove old symlink
os.symlink(new_target, path)
|