Created
May 12, 2017 09:36
-
-
Save cyriac/aa21c52df7e2ce7d497805b3239c8223 to your computer and use it in GitHub Desktop.
Fix broken links on Mackup when migrating dropbox location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
HOME_FOLDER = '/Users/cyriacthomas/' | |
NEW_DROPBOX_MACKUP_FOLDER = '/Users/cyriacthomas/Dropbox/Mackup/' | |
cmd = 'find {} -type l'.format(HOME_FOLDER) | |
files=os.popen(cmd).read() | |
_ = [] | |
commands = [] | |
for f in files: | |
if 'Mackup' in os.path.realpath(f): | |
_.append(f) | |
target = "{}{}".format(NEW_DROPBOX_MACKUP_FOLDER, | |
f.lstrip(HOME_FOLDER)) | |
commands.append("unlink {}".format(f)) | |
commands.append("ln -s {target} {f}".format(target=target, f=f)) | |
with open('restore.sh', 'w') as f: | |
for c in commands: | |
print>>f, c | |
print("Run sh ./restore.sh") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment