It is easy to convert a symlink into a hardlink with
ln -f (example)
It would also be easy to convert a hardlink (filenames
original) back to a symbolic link to
link->original in the case where you know both files and define yourself which one is the "original file". You could easily create a simple script
convert-known-hardlink-to-symlink that would result in something like:
convert-known-hardlink-to-symlink link original $ ls -li 3802465 lrwxrwxrwx 1 14 Dec 6 09:52 link -> original 3802269 -rw-rw-r-- 1 0 Dec 6 09:52 original
But it would be really useful if you had a script where you could define a working directory (default
./) and a search-directory where to search (default
/) for files with the same inode and then convert all those hard-links to symbolic-links.
The result would be that in the defined working directory all files that are hard-links are replaced with symbolic-links to the first found file with the same inode instead.
A start would be
find . -type f -links +1 -printf "%i: %p (%n)\n"