Skip to content

Instantly share code, notes, and snippets.

@jatubio
Last active August 29, 2015 14:23
Show Gist options
  • Save jatubio/ce97f6f663cdcab6ecbf to your computer and use it in GitHub Desktop.
Save jatubio/ce97f6f663cdcab6ecbf to your computer and use it in GitHub Desktop.
Compare directories first level names
@echo off
setlocal enabledelayedexpansion
SET DestinationDrive=Z
SET TotalDuplicated=0
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%
echo Comparing %source% with %destination%
if "%source%"=="" (
echo El origen está vacío
goto :EOF
)
if "%destination%"=="" (
echo El destino está vacío
goto :EOF
)
echo.
echo No Duplicados
for /D %%a in ("%source%\*.*") do call :unique "%%a" %destination%
echo.
echo.
echo Duplicados
for /D %%a in ("%source%\*.*") do call :duplicated "%%a" %destination%
echo.
echo Total %TotalDuplicated% duplicados.
goto :EOF
:unique
if not exist "%~2\%~n1" echo %~n1
goto :EOF
:duplicated
if exist "%~2\%~n1" echo %~n1 & set /a TotalDuplicated=%TotalDuplicated%+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
@jatubio
Copy link
Author

jatubio commented Jun 20, 2015

To be used after cloneln.bat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment