Created
January 31, 2016 09:52
-
-
Save raohmaru/3199ef79a4223cd3921d to your computer and use it in GitHub Desktop.
Create symbolic links in Windows from the subdirectories of a given directory
This file contains 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
@ECHO OFF | |
IF "%~1"=="" GOTO Continue | |
IF "%~1"=="-h" GOTO Continue | |
IF "%~2"=="" GOTO No2ndParam | |
IF NOT EXIST %1 GOTO NoWinDir1 | |
IF NOT EXIST %2 GOTO NoWinDir2 | |
PUSHD %1 | |
FOR /D %%G in ("*") DO ( | |
mklink /J "%~2\%%G" "%%G" | |
) | |
POPD | |
GOTO:EOF | |
:NoWinDir1 | |
ECHO %1 is not a valid directory. Type "create_symlink -h" to get help. | |
EXIT /B 0 | |
:NoWinDir2 | |
ECHO %2 is not a valid directory. Type "create_symlink -h" to get help. | |
EXIT /B 0 | |
:No2ndParam | |
ECHO Missing argument target_dir. Type "create_symlink -h" to get help. | |
EXIT /B 0 | |
:Continue | |
ECHO Creates a symlink in the target directory for each folder in the source directory. | |
ECHO Usage: create_symlink source_dir target_dir | |
ECHO[ | |
ECHO source_dir The source directory with subfolders to symlink | |
ECHO target_dir The target directory where to create the symlinks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment