I want to drop through my mp3 folders and create a sym link to each mp3 in a folder called links. I would like for my links to be relative to the directory structure rather than absolute. I tried this and no luck.

find . -name "*.mp3" -type l -delete; mp3="mp3"; for i in ./*/; do; ln -s  ../links/ "$i$mp3"; done

Can someone help please?

  • Looks like the * was omitted in my cmd line. should be. find . -name "*.mp3" -type l -delete; mp3="mp3"; for i in ./*/; do; ln -s ../links/ "$i$mp3"; done Jul 6, 2019 at 0:10
  • 1
    Please try a lot harder to explain this clearly.  You talk about creating, but you show a command that does deletes. Huh? Why?  What do you mean by “recursive”?  It would help if you showed an example before and after. … … … … … … … … … … … … … … … Please do not respond in comments; edit your question to make it clearer and more complete. Jul 6, 2019 at 0:39

1 Answer 1


Assuming that links is on the same level as your mp3 directory structure or above (or else you have to adjust the relative path ..):

cd /path/to/links
find .. -name "*.mp3" -type f -exec ln -s {} \;

Note that the mp3 files can have the same filenames and the first one found "wins" the symbolic link.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .