Skip to content

Instantly share code, notes, and snippets.

@jatubio
Last active August 29, 2015 14:23
Show Gist options
  • Save jatubio/418b653987eaf679d887 to your computer and use it in GitHub Desktop.
Save jatubio/418b653987eaf679d887 to your computer and use it in GitHub Desktop.
Clone first level subdirectories to destination using ln.exe
@echo off
setlocal enabledelayedexpansion
SET DestinationDrive=Z
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
)
echo Cloning %source% into %destination%
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
for /D %%a in ("%source%\*.*") do call :clone "%%a" "%destination%"
:clone
rem if not exist "%~2\%~n1" echo "C:\App\Files\Links Tools\ln\ln.exe" --backup --copy "%~1" "%~2\%~n1"
"C:\App\Files\Links Tools\ln\ln.exe" --backup --copy "%~1" "%~2\%~n1"
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
echo si
) 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