We have previously looked at using dired for managing files and switching dired into writeable mode for renaming multiple files. Here is a related tip to redirect symbolic links in dired.
Suppose you moved some data from one location to another and ended up with a bunch of broken symbolic links, you can easily edit those links to point to the new path. In the example below, I have links pointing to files in /old/path
and I want the to point to files in /new/dir
instead, so I do the following
- Use
C-x d
to enter dired and choose the directory with the files in - Use
C-x C-q
to turn dired into editing mode. You can then edit the file names by hand or - Use multiple cursors to edit the links in one go (you could also use e.g.
M-%
to do a query-replace). This changes the path of the links. - Use
C-c C-c
so apply the changes, orC-c C-k
to cancel
This is illustrated in the following animation.
This is just great – it feels like magic every time!