Guest User

Untitled

a guest
Dec 11th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import os
  4.  
  5. PREFIX = "some prefix"
  6.  
  7. for root, dirs, files in os.walk("."):
  8. dir_fd = os.open(root, os.O_DIRECTORY)
  9. for f in files:
  10. link_path = os.path.join(root, f)
  11. if os.path.islink(link_path):
  12. real_path = os.path.realpath(link_path)
  13. new_real_path = real_path[len(PREFIX):]
  14. print(new_real_path, "|", f, "|", root)
  15. os.unlink(link_path)
  16. os.symlink(new_real_path, f, dir_fd=dir_fd)
Add Comment
Please, Sign In to add comment