Created
April 23, 2011 08:16
-
-
Save hokorobi/938466 to your computer and use it in GitHub Desktop.
第一引数のディレクトリへ第二引数以降のファイル・ディレクトリのジャンクション・シンボリックリンクを作成するバッチ。(一部管理者権限必要)
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 | |
REM 引数チェック | |
if "%~2" == "" (goto USAGE) | |
set destAttribute=%~a1 | |
if not %destAttribute:~0,1%==d (goto USAGE) | |
REM シンボリックリンク作成先のディレクトリを取得 | |
set dest=%~1 | |
shift /1 | |
REM ファイルの処理 | |
:LOOP | |
if not exist "%~1" (goto SHIFT) | |
set targetAttribute=%~a1 | |
if %targetAttribute:~0,1%==d ( | |
call :EXEC mklink /j "%dest%\%~nx1" "%~1" | |
) else ( | |
call :EXEC mklink "%dest%\%~nx1" "%~1" | |
call :EXEC takeown /f "%dest%\%~nx1" | |
) | |
:SHIFT | |
shift /1 | |
if "%~1" == "" (goto EOF) else (goto LOOP) | |
:USAGE | |
echo USAGE: %~0 dest_dir files | |
:EOF | |
exit 0 | |
:EXEC | |
%* | |
if errorlevel 1 ( | |
echo %* | |
pause | |
exit 1 /b | |
) | |
exit 0 /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment