Auto rename symbolic link

0

I have a folder which contains many sub-folders which contains many images. I find it tedious to go into each folder to browse the images so I decided to create an empty folder and create symbolic links to all of the images with the following command (I'm on Ubuntu 11.10):

find /home/someuser/ParentImageFolder/Galleries/ -iname "*.jpg" -print -exec ln -s {} . \;

This works fine but the problem I am running into is that if there are two files with the same name in different folders, only one symbolic link gets created.

Can anyone provide a way for me to solve this so that even if there are two files with the same name, I will still get two symbolic links created when I run my command above.

Thanks.

Justin Kredible

Posted 2012-01-01T17:14:15.617

Reputation: 269

Just curious, but why don't you just symlink the whole folders inside the galleries? This way you wouldn't need to bother about the file names: find /wherever -type d -exec ln -vs {} . \; (or something like that) – runlevel0 – 2018-04-18T08:13:40.143

Answers

1

Add --backup=numbered to ln and .~n~ will be appended if a name already exist.

micke

Posted 2012-01-01T17:14:15.617

Reputation: 3 001