Symlink all Directories inside one directory to another directory

nassymlink

I am using a NAS(synology/xpenology) currently with 1 Drive /volume1/Drive is the share.
I have other shares on this Drive /volume1/Drive/SeriesPC its a share connected to my drive on my pc.

Now I want to symlink every directory from SeriesPC to the Show folders on /volume1/Drive/Series

example:

Inside /volume1/Drive/Series

  • The 100
  • NCIS
  • NCIS La
  • NCIS New Orleans

and inside /volume1/Drive/SeriesPC

  • 24
  • Alias
  • The Blacklist
  • Under the Dome

now I want it like this

Inside /volume1/Drive/Series

  • The 100
  • NCIS
  • NCIS La
  • NCIS New Orleans
  • 24 > /volume1/Drive/SeriesPC/24
  • Alias > /volume1/Drive/SeriesPC/Alias
  • The Blacklist > /volume1/Drive/SeriesPC/The Blacklist
  • Under the Dome > /volume1/Drive/SeriesPC/Under the Dome

This without needing to create 24/Alias/The Blacklist/Under the Dome directories manually

So every directory inside SeriesPC must get symlinked to Series

I hope I am here right and explained it good enough

Best Answer

I would do the following if you want all the files/directories under SeriesPC to be linked:

cd /volume1/Drive/SeriesPC
for i in * ; do ln -s "$PWD/$i" /volume1/Drive/Series/ ; done

If not everything under SeriesPC should be linked make sure you can find just the directories that you need e.g. using find * -maxdepth 1 -type d and then do:

cd /volume1/Drive/SeriesPC
find * -maxdepth 1 -type d -exec ln -s $PWD/{} /volume1/Drive/Series/ \;
Related Question