Created
August 20, 2025 05:38
-
-
Save singularitti/2e97cd79213e321dc92c8eddbd1de1cc to your computer and use it in GitHub Desktop.
Symlink all immediate subfolders from one directory into another #Shell #OS #symlink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| link_subfolders() { | |
| if [ $# -ne 2 ]; then | |
| echo "Usage: link_subfolders <source_dir> <target_dir>" | |
| return 1 | |
| fi | |
| local src="$1" | |
| local dst="$2" | |
| # Ensure target exists | |
| mkdir -p "$dst" | |
| # Link only immediate subdirectories of source into target | |
| find "$src" -mindepth 1 -maxdepth 1 -type d -exec ln -s {} "$dst" \; | |
| } | |
| # Usage: link_subfolders /path/to/source /path/to/target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment