I had painstakingly gone through and created symlnks to a whole host of files in my system. I couldn't use aliases because they were failing to be copied with RSync, and also certain apps I use to access my home system remotely over iOS, couldn't handle Aliases but worked fine with symlinks.

Now however I had to change some hard drives around, and my original files are now in a new location. This of course means all my symlinks have broken.

Aliases deal with this just fine but as stated above, I have to stick with symlinks. Is there any way to mass-edit these symlinks? I just need to change the name of the drive in the path. The old location was for example:

/Volumes/Old Drive/path/to/file

the new one is:

/Volumes/New Drive/path/to/file

Seems like there should be a workable command line way to do this since they'll all require the same change. I found at least one utility (Make Symlink) which claims to allow this, but it appears to be many years old and looks abandoned. I couldn't even manage to decompress the .sit archive it was packed in.

EDIT: I found this page, which suggests that in unix anyway, proper us of ln should do the trick, but so far it doesn't appear to do anything - not even output any error message when pointed to a non-existent symlink.


Got it! Turns out ln is the answer after all, but I had an error in my path.

Here is a functional command line for anyone who might need to edit a symlink "in place" in the future:

ln -f -s /path/to/new/location/of/original /path/to/location/of/broken/symlink/

Notice that you're not actually pointing all the way to the broken symlink itself, but to the directory that contains the broken symlink. This assumes that the expected name of the symlink, is identical to the original name of the linked item.

This is of course for fixing a single link, but from here I can imagine it wouldn't be overly difficult to script a solution that applied something like this recursively.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .