[opensuse] moving links from one disk to an other
Hello. I have to move my photo collections to a new disk. with rsync, no problem. however I have one. I have lot of links in a folder, say: photo/ linkto2020 linkto2019 and for example, linkto2020 -> /run/media/jdd/intenso5to2/archives2020/photos to link to the real photo folder on the very same disk When I copy the link it keeps unchanged my new disk (bigger) is Seagate6to how can I have the link reference the new disk? (have Seagate in place of intenso) I'm lost in rsync manual about links :-( thanks jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
jdd -- ...and then jdd@dodin.org said... % ... % % linkto2020 -> /run/media/jdd/intenso5to2/archives2020/photos % % to link to the real photo folder on the very same disk % % When I copy the link it keeps unchanged That's a feature, not a bug :-) % % my new disk (bigger) is Seagate6to % % how can I have the link reference the new disk? (have Seagate in % place of intenso) [snip] Because you have full path names, you're gonna have trouble. Since you're on the same disk, you should use relative links intenso5to2/archives2020/photos ../../archives2020/photos so that you don't care where it's mounted. You're going to have to remake all of your links in any case; the question is whether you change them once to point relatively or make them absolute links again to the new disk ... and perhaps repeat in a few years :-) You can of course do this on the new disk and leave your old safe as a backup. HTH & HAND :-D -- David T-G See http://justpickone.org/davidtg/email/ See http://justpickone.org/davidtg/tofu.txt -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 20/08/2020 à 16:42, David T-G a écrit :
jdd --
...and then jdd@dodin.org said... % ... % % linkto2020 -> /run/media/jdd/intenso5to2/archives2020/photos % % to link to the real photo folder on the very same disk % % When I copy the link it keeps unchanged
That's a feature, not a bug :-)
yes, I know :-(. I was once tricked by this, a link removed, but from the trash can it still pointed to the data :-)
Because you have full path names, you're gonna have trouble. Since you're on the same disk, you should use relative links
I did them with Dolphin. Given my data structure it's pretty hard to make them in cli :-(
You're going to have to remake all of your links in any case; the question is whether you change them once to point relatively or make them absolute links again to the new disk ... and perhaps repeat in a few years :-) You can of course do this on the new disk and leave your old safe as a backup.
in fact, Dolphin allows me to edit the target, but the result is unexpected, I need to experiment more thanks jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 20/08/2020 à 17:22, jdd@dodin.org a écrit :
in fact, Dolphin allows me to edit the target, but the result is unexpected, I need to experiment more
works. and ln -s /home/Data1 /home/Stores/abc ln -f -s /home/Data2 /home/Stores/abc so my goal is to find the old target (from intenso), edit it and relink, same as above, but without knowing the first target (have to be found trough the link) thanks for help jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 20/08/2020 17.22, jdd@dodin.org wrote:
Le 20/08/2020 à 16:42, David T-G a écrit :
...and then jdd@dodin.org said... % ... % % linkto2020 -> /run/media/jdd/intenso5to2/archives2020/photos % % to link to the real photo folder on the very same disk % % When I copy the link it keeps unchanged
That's a feature, not a bug :-)
yes, I know :-(. I was once tricked by this, a link removed, but from the trash can it still pointed to the data :-)
Because you have full path names, you're gonna have trouble. Since you're on the same disk, you should use relative links
I did them with Dolphin. Given my data structure it's pretty hard to make them in cli :-(
'mc' permits creation of links, or editing them later. I see options to create relative or absolute symlinks, or hardlinks. The obvious snag is that is a "text" tool, so if they are photos you see their names, not the contents. Not instantly, that is. There are GUI tools similar to 'mc', but not that powerful. I just looked at "gnome-commander", it does not seem to do links. Same thing with "krusader" - but this one does generate a tiny preview of files if you ask. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Le 20/08/2020 à 20:56, Carlos E. R. a écrit :
'mc' permits creation of links, or editing them later. I see options to create relative or absolute symlinks, or hardlinks.
I use it pretty often (in fact I need it on any server), but never used it to link. Will get a look
The obvious snag is that is a "text" tool, so if they are photos you see their names, not the contents. Not instantly, that is.
not a problem, links are to folders, not images thanks jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 20/08/2020 à 22:20, jdd@dodin.org a écrit :
Le 20/08/2020 à 20:56, Carlos E. R. a écrit :
'mc' permits creation of links, or editing them later. I see options to create relative or absolute symlinks, or hardlinks.
I use it pretty often (in fact I need it on any server), but never used it to link. Will get a look
works well. Not to edit previous links, but much faster than cli to create new. accceptable. thanks jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 20/08/2020 à 22:20, jdd@dodin.org a écrit :
Le 20/08/2020 à 20:56, Carlos E. R. a écrit :
'mc' permits creation of links, or editing them later. I see options to create relative or absolute symlinks, or hardlinks.
I use it pretty often (in fact I need it on any server), but never used it to link. Will get a look
in fact mc is very clever. I *can* edit the link target, replacing the absolute link part by ../../ wonderfull :-) thanks to make me discover this option in my for long beloved mc :-)) jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 20/08/2020 23.38, jdd@dodin.org wrote:
Le 20/08/2020 à 22:20, jdd@dodin.org a écrit :
Le 20/08/2020 à 20:56, Carlos E. R. a écrit :
'mc' permits creation of links, or editing them later. I see options to create relative or absolute symlinks, or hardlinks.
I use it pretty often (in fact I need it on any server), but never used it to link. Will get a look
in fact mc is very clever. I *can* edit the link target, replacing the absolute link part by ../../
Exactly :-)
wonderfull :-)
thanks to make me discover this option in my for long beloved mc :-))
isn't a lovely tool? I know some one, a geek, scientific, engineer, clever friend that makes fun of me when he sees me using mc and invents all sort of crazy histories, like me using Norton Commander in the past and so wanting something familiar now. Gosh. There simply doesn't exist a GUI tool that does as much as 'mc' does. Not counting that you can add menu entries with some sort of script language it has. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc. http://silk.apana.org.au/fc2development.php -- Evolution as taught in public schools, like religion, is based on faith, not on science. Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 21/08/2020 à 04:52, Felix Miata a écrit :
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc.
any real gui? I use mostly Dolphin, that is very capable, and mc when Dolphin can't jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 21/08/2020 04.52, Felix Miata wrote:
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc.
'fcl' doesn't seem to be available in oS. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
* Carlos E. R. <robin.listas@telefonica.net> [08-21-20 06:30]:
On 21/08/2020 04.52, Felix Miata wrote:
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc.
'fcl' doesn't seem to be available in oS.
silk.apana.org.au provides rpms build for Leap 15.1 and Tumbleweed but none for Leap 15.2. also a repo. but I tested and was not overly impressed with fcl, especially the limited display window. to each his own. -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.org openSUSE Community Member facebook/ptilopteri Photos: http://wahoo.no-ip.org/piwigo paka @ IRCnet freenode -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Patrick Shanahan composed on 2020-08-21 07:21 (UTC-0400):
* Carlos E. R. composed:
Felix Miata wrote:
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc.
'fcl' doesn't seem to be available in oS.
silk.apana.org.au provides rpms build for Leap 15.1 and Tumbleweed but none for Leap 15.2. also a repo.
Leap is Leap, 15.x for fcl purposes: [FCL] autorefresh=0 baseurl=http://silk.apana.org.au/rpm-opensuse15-unstable-dev enabled=1 gpgcheck=1 gpgkey=http://silk.apana.org.au/debian/fc.public.key name=FCL type=rpm-md
but I tested and was not overly impressed with fcl, especially the limited display window. to each his own.
Did you try any options? http://fm.no-ip.com/SS/fcl1155.jpg What image can't show is it has more hotkey options for recent*. Like mc, it takes a while to discover all its power. I've been using Havard's File Commander for 27 years or more, as it was migrated from its OS/2 origin into Linux. -- Evolution as taught in public schools, like religion, is based on faith, not on science. Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
* Felix Miata <mrmazda@earthlink.net> [08-21-20 13:49]:
Patrick Shanahan composed on 2020-08-21 07:21 (UTC-0400):
* Carlos E. R. composed:
Felix Miata wrote:
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc.
'fcl' doesn't seem to be available in oS.
silk.apana.org.au provides rpms build for Leap 15.1 and Tumbleweed but none for Leap 15.2. also a repo.
Leap is Leap, 15.x for fcl purposes:
[FCL] autorefresh=0 baseurl=http://silk.apana.org.au/rpm-opensuse15-unstable-dev enabled=1 gpgcheck=1 gpgkey=http://silk.apana.org.au/debian/fc.public.key name=FCL type=rpm-md
but I tested and was not overly impressed with fcl, especially the limited display window. to each his own.
Did you try any options?
http://fm.no-ip.com/SS/fcl1155.jpg
What image can't show is it has more hotkey options for recent*.
Like mc, it takes a while to discover all its power. I've been using Havard's File Commander for 27 years or more, as it was migrated from its OS/2 origin into Linux.
I didn't care for the smallish display window, but that was in plasma5. I didn't look in a tty. But I can open mc in any size window I wish. Istr file commander on os/2, but I have slept once or twice since then ... -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.org openSUSE Community Member facebook/ptilopteri Photos: http://wahoo.no-ip.org/piwigo paka @ IRCnet freenode -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 21/08/2020 à 19:43, Felix Miata a écrit :
What image can't show is it has more hotkey options for recent*.
yet not a gui like dolphin :-( jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
jdd composed on 2020-08-21 20:54 (UTC+0200):
Felix Miata composed:
What image can't show is it has more hotkey options for recent*.
yet not a gui like dolphin :-(
Precisely why it's great, designed for touch-typing keyboard users, yet works in GUI, as it did in OS/2 in 1992, where it was one of many morphed off of John Socha's Norton Commander, before the first PC GUIs came to market. https://en.wikipedia.org/wiki/Norton_Commander#Norton_Commander-inspired_sof... -- Evolution as taught in public schools, like religion, is based on faith, not on science. Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 21/08/2020 13.21, Patrick Shanahan wrote:
* Carlos E. R. <> [08-21-20 06:30]:
On 21/08/2020 04.52, Felix Miata wrote:
Carlos E. R. composed on 2020-08-21 03:11 (UTC+0200):
There simply doesn't exist a GUI tool that does as much as 'mc' does.
By itself it's not enough for me, possibly because there's so little I can learn from a man page. For vttys I fully agree. but in GUI I spend considerably more time in fcl than mc.
'fcl' doesn't seem to be available in oS.
silk.apana.org.au provides rpms build for Leap 15.1 and Tumbleweed but none for Leap 15.2. also a repo.
I don't see anything named fcl in there, no rpms. I see something in http://silk.apana.org.au/fc2development.php, but this is not referred to in the main page. Only unstable branch. The stable seems to be: <http://silk.apana.org.au/pub/fcl/filecommander-2.40-release1_opensuse10.i586.rpm> which is ancient. unstable: <http://silk.apana.org.au/pub/fcl/nightly/filecommander-2.50-vgit_1753_opensuse15.x86_64.rpm>
but I tested and was not overly impressed with fcl, especially the limited display window. to each his own.
I'm not impressed either. I get a standalone "GUI" window containing text that can not be resized. The button for "menu" does nothing, it is a user local menu. There is F1 to see the possible commands. There are things one can do if one remembers the hotkey for it - but without a menu, one has to remember them. Uninstalling. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
On 8/20/20 10:22 AM, jdd@dodin.org wrote:
I did them with Dolphin. Given my data structure it's pretty hard to make them in cli :-(
That is like "Tap Dancing On Landmines", or "Playing Russian Roulette". Perhaps I'm just jaded, or perhaps it's from 20 years of Linux experience, but you always want to create a maintain your data layout from the command line. There is never any ambiguity whether absolute or relative links are used, etc.. What you need to do on the new disk is figure out where all the file live relative to your "links directory" and then simply replace all absolute links with relative ones. Use the -f option to overwrite the absolute link with relative ones. E.g. $ ln -sf ../relative/path/to/target linkname You can probably build the list of links with the 'find' command an a '-type d' to select the directories needed and a '-name glob' You probably want to cd /path/on/new/disk/photos Then create a list of the directories you need to link relative to that location (you can redirect the output from find to a 'newlinks' text file if you need to edit it before creating the links). Then just loop over the contents of the 'newlinks' file replacing the symlinks on the new disk: while read -r newlnk; do ln -sf "$newlink" ## name will default to last component of $newlink done < newlinks Or if you want to give each of the symlinks a custom name, edit the 'newlinks' file and add a second column with the custom link name and do: while read -r newlnk lnkname; do ln -sf "$newlink" "lnkname" done < newlinks You can skip the 'newlinks' file an simply replace them all based on the output of `find` if there are no changes or edits needed. You may also be able to use globing "*/*", etc.. instead of find. It just depends on what the layout is. -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 8/20/20 4:48 PM, David C. Rankin wrote:
while read -r newlnk; do ln -sf "$newlink" ## name will default to last component of $newlink done < newlinks
Or if you want to give each of the symlinks a custom name, edit the 'newlinks' file and add a second column with the custom link name and do:
while read -r newlnk lnkname; do ln -sf "$newlink" "lnkname" done < newlinks
Of course without typos it would be: while read -r newlnk; do ln -sf "$newlnk" ## name will default to last component of $newlink done < newlinks while read -r newlnk lnkname; do ln -sf "$newlnk" "lnkname" done < newlinks -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 20/08/2020 23.48, David C. Rankin wrote:
On 8/20/20 10:22 AM, jdd@dodin.org wrote:
I did them with Dolphin. Given my data structure it's pretty hard to make them in cli :-(
That is like "Tap Dancing On Landmines", or "Playing Russian Roulette". Perhaps I'm just jaded, or perhaps it's from 20 years of Linux experience, but you always want to create a maintain your data layout from the command line. There is never any ambiguity whether absolute or relative links are used, etc..
What you need to do on the new disk is figure out where all the file live relative to your "links directory" and then simply replace all absolute links with relative ones. Use the -f option to overwrite the absolute link with relative ones. E.g.
$ ln -sf ../relative/path/to/target linkname
'mc' allows direct edit of the target of a symlink. If you get it wrong, it tells you instantly that it is wrong by displaying it in red and with a '!' in front instead of '~'. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Le 20/08/2020 à 23:48, David C. Rankin a écrit :
On 8/20/20 10:22 AM, jdd@dodin.org wrote:
I did them with Dolphin. Given my data structure it's pretty hard to make them in cli :-(
That is like "Tap Dancing On Landmines", or "Playing Russian Roulette".
no. It's not on essential data. In fact, I have my multimedia data sorted by years and grouped by decades (10 years), because it covers 1860->today, it's hard to follow in digikam, but one can have a centralized digikam folder with symlink. if ever I lose links, I still can rebuild the database -all is also stored in images- but it's a one day long work for the computer :-)
There is never any ambiguity whether absolute or relative links are used, etc...
but there are many other ways to lose data :-()
What you need to do on the new disk is figure out where all the file live relative to your "links directory" and then simply replace all absolute links with relative ones. Use the -f option to overwrite the absolute link with relative ones. E.g.
yes. I have to replace /run/media/jdd/intenso5to2 with ../../ (my digikam folder is always at the same place, relative to the data. but I have to figure the link target I know the link location I need some sort of, but this code is not working ($j and $i are identical - my bash knowledge is bad :-( #!/bin/sh for i ; do j=$(readlink $i) ; k=sed -i 's///run/media/jdd/intenso5to2/../..//g' $j ; ln -sf $k $i ; done thanks helping jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 8/21/20 1:58 AM, jdd@dodin.org wrote:
#!/bin/sh for i ; do j=$(readlink $i) ; k=sed -i 's///run/media/jdd/intenso5to2/../..//g' $j ; ln -sf $k $i ; done
Are you linking directories only are all files? If you give a 'tree' (just a representative directory/file example), I"m happy to help you write a short script to automate rebuilding your links (I do something similar with photos in Gallery2) How you feed your loop will depend on how deeply nested your file storage is. You "day long" computing can be reduced to just a few minutes by avoiding spawning additional subshells within the body of your loop. The command-substitution with sed will require 2 subshells per-iteration. That is where your time comes from. With bash, parameter expansions will avoid the additional subshells. You can also do it all within a single call to awk which would be orders of magnitude faster. -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 21/08/2020 à 23:47, David C. Rankin a écrit :
On 8/21/20 1:58 AM, jdd@dodin.org wrote:
#!/bin/sh for i ; do j=$(readlink $i) ; k=sed -i 's///run/media/jdd/intenso5to2/../..//g' $j ; ln -sf $k $i ; done
Are you linking directories only are all files?
only directories. Places are various, the initial link was ok, so it's enough to edit it
How you feed your loop will depend on how deeply nested your file storage is.
wont work, too many exceptions in the tree :-(
You "day long" computing can be reduced to just a few minutes by avoiding
the day long is to rebuild the digikam database, not for linking if you can find why the above script don't works, it will be ok for me, thanks jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Hello, On Sat, 22 Aug 2020, jdd@dodin.org wrote:
Le 21/08/2020 à 23:47, David C. Rankin a écrit :
On 8/21/20 1:58 AM, jdd@dodin.org wrote:
#!/bin/sh for i ; do j=$(readlink $i) ; k=sed -i 's///run/media/jdd/intenso5to2/../..//g' $j ; ln -sf $k $i ; done [..] if you can find why the above script don't works, it will be ok for me,
You need to either escape the '/' not used as sed's s/// command-delimiters or use other delimiters. And of course you need to use a command-substitution just as you did for the j=. Also, you should always quote your variables on acces. I.e. either for i ; do j="$(readlink "$i")"; k="$(sed -i 's/\/\/run\/media\/jdd\/intenso5to2/..\/..\//g' "$j")"; ln -sf "$k" "$i"; done or for i ; do j="$(readlink "$i")"; k="$(sed -i 's@//run/media/jdd/intenso5to2@../../@g' "$j")"; ln -sf "$k" "$i"; done Or even better, replace the sed with a bash-substitution: for link ; do target="$(readlink "$link")"; ln -sf "${target/\/\/run\/media\/jdd\/intenso5to2/..\/..\/}" "$link"; done HTH, -dnh -- panic("Oh boy, that early out of memory?"); linux-2.2.16/arch/mips/mm/init.c -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2020-08-21 08:58, jdd@dodin.org wrote:
I need some sort of, but this code is not working ($j and $i are identical - my bash knowledge is bad :-(
#!/bin/sh for i ; do j=$(readlink $i) ; k=sed -i 's///run/media/jdd/intenso5to2/../..//g' $j ; ln -sf $k $i ; done
The task is 3-fold: 1. find symlinks with non-relative targets. 'find' can do that with: find -type l -lname '/*' ... 2. Determine the link target and change only those with an existing target (a link target can contain arbitrary information). The 'readlink' tool does that with the -e option. 3. Create the same symlink in place with a relative target. 'ln' has the '-r' (--relative) option, and -f to remove the existing link. This boils down to e.g.: find . -type l -lname '/*' \ -execdir \ sh -c 'rel=$( readlink -e "{}" ) && ln -sfrv "$rel" "{}" ' \ \; find will pass the link names where "{}" is mentioned in the above. Instead of having the shell code as -execdir argument one could of course also put it into a separate script. No warranty - if you want to use it, then please test in a separate directory hierarchy first whether the result is what you want/need. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 23/08/2020 à 18:41, Bernhard Voelker a écrit :
On 2020-08-21 08:58, jdd@dodin.org wrote:
I need some sort of, but this code is not working ($j and $i are identical - my bash knowledge is bad :-(
#!/bin/sh for i ; do j=$(readlink $i) ; k=sed -i 's///run/media/jdd/intenso5to2/../..//g' $j ; ln -sf $k $i ; done
The task is 3-fold:
1. find symlinks with non-relative targets. 'find' can do that with: find -type l -lname '/*' ...
I don't need this part, I know where they are :-) (but it don't hurt :-)
2. Determine the link target and change only those with an existing target (a link target can contain arbitrary information). The 'readlink' tool does that with the -e option.
I know them as well
3. Create the same symlink in place with a relative target. 'ln' has the '-r' (--relative) option, and -f to remove the existing link.
This boils down to e.g.:
find . -type l -lname '/*' \ -execdir \ sh -c 'rel=$( readlink -e "{}" ) && ln -sfrv "$rel" "{}" ' \ \;
find will pass the link names where "{}" is mentioned in the above. Instead of having the shell code as -execdir argument one could of course also put it into a separate script.
No warranty - if you want to use it, then please test in a separate directory hierarchy first whether the result is what you want/need.
easy, I will test it, thanks jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 8/20/20 9:30 AM, jdd@dodin.org wrote:
I have lot of links in a folder, say:
photo/ linkto2020 linkto2019
and for example,
linkto2020 -> /run/media/jdd/intenso5to2/archives2020/photos
to link to the real photo folder on the very same disk
The trick is to use relative links instead of absolute links. So you would have used something like: linkto2020 -> ../archives2020/photos Note that I am guessing here, because I don't know the directory structure of your disk. If you use relative links (for links to the same physical disk), then they work independently of where the disk is mounted. You have to do that at the time you create the links. Of course, you can remove an existing absolute link and replace it with a relative link.
When I copy the link it keeps unchanged
And if you were using relative links, it would still do what you want. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (9)
-
Bernhard Voelker
-
Carlos E. R.
-
David C. Rankin
-
David Haller
-
David T-G
-
Felix Miata
-
jdd@dodin.org
-
Neil Rickert
-
Patrick Shanahan