Skip to content

Instantly share code, notes, and snippets.

@beatcracker
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beatcracker/6180a20a4b07219bdaaf to your computer and use it in GitHub Desktop.
Save beatcracker/6180a20a4b07219bdaaf to your computer and use it in GitHub Desktop.
Creates destination directory where all content is symlinked from the source directory. Uses https://github.com/JDeuce/symlink.bat
rem Wrapper for https://github.com/JDeuce/symlink.bat .
rem Creates destination directory where all content
rem is symlinked from the source directory.
rem Usage: SymlinkDirContent.cmd "x:\source" "x:\destination"
rem Originally created for Windows Authentication install
rem of the http://bonobogitserver.com to avoid creating two
rem identical directories, which differ only by one web.config file.
rem @echo off
if [%1] equ [] (
echo Source path not specified!
goto :eof
) else (
rem note %~1 = 1 without quotes
set src=%~1
rem does string have a trailing slash? if so remove it
if %src:~-1%==\ set src=%src:~0,-1%
)
rem Check if src is a directory
if not exist %src%\ (
echo Source is not a directory!
goto :eof
)
if [%2] equ [] (
echo Destination path not specified!
goto :eof
) else (
set dst=%~2
rem does string have a trailing slash? if so remove it
if %dst:~-1%==\ set dst=%dst:~0,-1%
)
if not exist %dst%\ (
echo Creating destination directory
mkdir %dst%
)
for /f "delims==" %%k in ('dir "%src%" /b') do (
echo Creating symlink: %src%\%%k -^> %dst%\%%k
symlink.bat %src%\%%k %dst%\%%k
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment