-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathln.bat
More file actions
23 lines (23 loc) · 581 Bytes
/
ln.bat
File metadata and controls
23 lines (23 loc) · 581 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@echo off
:: ln [-s|-H|-J] TARGET LINKNAME
:: -s symlink (auto /D for directories)
:: -H hard link (files only)
:: -J junction (directories)
if "%~3"=="" (echo Usage: ln [-s ^| -H ^| -J] ^<target^> ^<linkname^> & exit /b 1)
set "mode=%~1"
set "target=%~2"
set "link=%~3"
if /I "%mode%"=="-s" (
if exist "%target%\NUL" (
mklink /D "%link%" "%target%"
) else (
mklink "%link%" "%target%"
)
) else if /I "%mode%"=="-H" (
mklink /H "%link%" "%target%"
) else if /I "%mode%"=="-J" (
mklink /J "%link%" "%target%"
) else (
echo ln: unknown mode "%mode%"
exit /b 1
)