Last active
August 29, 2015 14:23
-
-
Save jatubio/6744f762d7de5d14046e to your computer and use it in GitHub Desktop.
Clone source to destination using ln.exe
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
@echo off | |
setlocal enabledelayedexpansion | |
setlocal | |
set DestinationDrive=Z | |
set includeDir= | |
goto :include | |
:main | |
call :source "%~1" | |
rem echo source set to %source% from %~1 | |
call :destination "%~2" "%source%" | |
rem echo destination set to %destination% from %~2 and %source% | |
if [%source%]==[] ( | |
echo El origen está vacío | |
goto :EOF | |
) | |
if [%destination%]==[] ( | |
echo El destino está vacío | |
goto :EOF | |
) | |
set info=Cloning "%source%" into "%destination%" | |
if defined includeDir set info=%info% with params: %includeDir% | |
echo %info% | |
pause Press a key to continue | |
rem for /D %%a in (%1\*.*) do "C:\App\Files\Links Tools\ln\ln.exe" --backup --copy "%%a" "%2\%%~na" | |
rem for /D %%a in (%1\*.*) do echo "C:\App\Files\Links Tools\ln\ln.exe" --backup --copy %%a %2%%~na | |
call :clone "%source%" "%destination%" | |
endLocal | |
goto :EOF | |
:include | |
set include=false | |
if [%1]==[-I] set include=true | |
if [%1]==[-i] set include=true | |
if %include%==true ( | |
set includeDir=%includeDir% --includedir "%~2" | |
shift | |
shift | |
goto :include | |
) | |
goto :main | |
:clone | |
rem if not exist "%~2\%~n1" echo "C:\App\Files\Links Tools\ln\ln.exe" --backup --copy "%~1" "%~2\%~n1" | |
echo Cloning...(This may take a while) | |
if defined includeDir ( | |
"C:\App\Files\Links Tools\ln\ln.exe" %includeDir% --backup --copy "%~1" "%~2" | |
) else ( | |
"C:\App\Files\Links Tools\ln\ln.exe" --backup --copy "%~1" "%~2" | |
) | |
rem rd /s /q "%~1" | |
goto :EOF | |
:source | |
set source=%CD% | |
IF not [%~1]==[] ( | |
set source=%~1 | |
) | |
goto :EOF | |
:destination | |
IF NOT [%~1]==[] ( | |
SET destination=%~1 | |
) else ( | |
set destination=%DestinationDrive%:%~pn2 | |
) | |
goto :EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add
-i
parameter to pass include dirs.Usage:
Samples:
%DestinationDrive%
same name folder.%DestinationDrive%
same name folder.