Tool to automatically update symlinks when moving files
VirginSnow at vfemail.net
VirginSnow at vfemail.net
Wed Jul 1 12:21:50 EDT 2009
Does anyone know of a tool that can automatically update symbolic
links when moving files around on a filesystem, so as to maintain
symlink consistency?
For example:
/off/the/cuff/example/cake # regular file
/off/the/cuff/example/coffee -> ../../../handle/drink
/off/the/handle/drink # regular file
/off/the/handle/food -> ../../cuff/example/cake
$ symlink_updating_mv --top=/off/the /off/the/cuff/example /off/the
should result in:
/off/the/cuff # directory
/off/the/example/cake # regular file
/off/the/example/coffee -> ../../handle/drink # removed one "../"
/off/the/handle/drink # regular file
/off/the/handle/food -> ../../example/cake # removed "cuff/"
That is, both links pointing into and out from the directory being
moved were updated. The links should also be updated whether they are
relative or absolute symbolic links, too.
Yes, I realize that this operation requires scanning the intire tree
rooted at "--top". However, I do not anticipate renaming directories
frequently, so that particular cost would be acceptable to me. Still,
I would like to be able to avoid having to manually relink files when
I shuffle them around.
Yes, I know that this problem *could* also be solved by using hard
links. However, using hard links to directories is non-posix,
requires root privilege, and can create infinite directory structures
which cause programs that recursively descend directories (like ls,
find, grep, etc.) to enter infinite recursion. Yuck.
More information about the gnhlug-discuss
mailing list