Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import os
- PREFIX = "some prefix"
- for root, dirs, files in os.walk("."):
- dir_fd = os.open(root, os.O_DIRECTORY)
- for f in files:
- link_path = os.path.join(root, f)
- if os.path.islink(link_path):
- real_path = os.path.realpath(link_path)
- new_real_path = real_path[len(PREFIX):]
- print(new_real_path, "|", f, "|", root)
- os.unlink(link_path)
- os.symlink(new_real_path, f, dir_fd=dir_fd)
Add Comment
Please, Sign In to add comment