Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Up until Delphi 7, .ddp files were used to store the Diagram Portfolios. Often these files were empty like `Empty.ddp`, so this batch file helps to clean up those.
@echo off
if #%1#==## goto :help
call :main %*
goto :eof
echo Syntax: %0 Project-Root-Path [Empty.ddp]
echo This will delete all empty DDP files, with the default second paramameter being "%~dp0Empty.ddp"
goto :eof
set emptyDDP=%2
if #%2#==## set emptyDDP=%~dp0Empty.ddp
echo emptyDDP=%emptyDDP%
set root=%1
::echo root=%root%
::Does string have a trailing slash? if so remove it
if %root:~-1%==\ SET root=%root:~0,-1%
::echo root=%root%
for /R %root% %%f in (*.ddp) do call :compare "%%f"
goto :eof
::echo %1
:: do not compare the predefined empty one itself, otherwise it gets deleted
if /I %1=="%emptyDDP%" goto :eof
::echo before %ERRORLEVEL%
FC %1 "%emptyDDP%" > nul
::echo after %ERRORLEVEL%
if ERRORLEVEL 1 goto :keep
if ERRORLEVEL 0 goto :delete
echo ### Wrong ERRORLEVEL
goto :eof
echo keep %1
goto :eof
del %1
goto :eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.