Blast from the past: Deleting empty Delphi .ddp files
Posted by jpluimers on 2014/12/09
In Delphi 6 and 7, .ddp files were used to store the Delphi Diagram Portfolios.
Often these files were created empty like `Empty.ddp`, so it pays to clean up those.
The below batch file (part of the free BeSharp.net code repository) will help with that. Make sure you download this Empty.ddp file and put it in the same directory as the batch file.
Call the batch file with the path to the directory tree you want to delete the Empty .ddp files from.
This file contains 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 | |
if #%1#==## goto :help | |
setlocal | |
call :main %* | |
endlocal | |
goto :eof | |
:help | |
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 | |
:main | |
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 | |
:compare | |
::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 | |
:keep | |
echo keep %1 | |
goto :eof | |
:delete | |
del %1 | |
goto :eof | |
:eof |
–jeroen
Wow – people still working on Delphi 6 and 7 based code! Got new votes for answer to get rid of empty DDP files « The Wiert Corner – irregular stream of stuff said
[…] Blast from the past: Deleting empty Delphi .ddp files […]