Symlink – How to Copy Folder Structure and Create Symbolic Links

file-copyrecursivesymlink

I have a folder SOURCE that contains several sub-level folders, each with its own files.

I want to copy this folder in a new folder COPY where I need to copy the directory structure but keep the files as symbolic links to the original files in SOURCE and its subfolders.

Best Answer

Here's the solution on non-embedded Linux and Cygwin:

cp -as SOURCE/ COPY

Note that SOURCE must be an absolute path and have a trailing slash. If you want to give a relative path, you can use

cp -as "$(pwd)/SOURCE/" COPY
Related Question