$ find /path/to/dir -type l -exec sh -c 'cp --remove-destination "$(readlink "{}")" "{}"' \;
April 24, 2012, 3:29 p.m.
—
Janos
Explanation
- All the double quoting is necessary to handle filenames with spaces.
- Calling
sh
with -exec
is necessary to evaluate readlink
for each symlink
Limitations
The BSD implementation of cp
does not have the --remove-destination
flag.