If, like us at Conchango you are developing Reports and Process Templates for Team Foundation Server, you will end up with a lot of defunct Team Projects that are taking up space for no reason on your development server (and also slowing down the Warehouse refresh cycle).
Looking for an easy way to clean up, I found the command-line tool TFSDeleteProject.exe (typically in %ProgramFiles%\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies or Tools depending on whether you are on Beta 3 Refresh or a later build...) and cobbled together this batch file to call it. I thought I'd share as people forget the power of "FOR /L" in a batch file and start using funkier things like Monad ;)
The following batch file will delete Projects test1 to test100 inclusive (and associated Build items, Work Items, Reports deployed to Reporting Services and the WSS site) when run on the application server:
@echo off
c:
cd\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies
set TEAMPROJECTPREFIX=test
FOR /L %%G IN (1,1,100) DO echo Deleting Project: %TEAMPROJECTPREFIX%%%G && tfsdeleteproject.exe /q /force /TeamFoundationServer:%COMPUTERNAME% %TEAMPROJECTPREFIX%%%G
If you are interested, this could also be achieved in one line of Monad (Beta 2) script as follows ;)
$prefix="test";cd "\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies";for($x=1;$x -le 100;$x++){echo "Deleting Project $prefix$x";.\TFSDeleteProject.exe /q /force /TeamFoundationServer:$env:COMPUTERNAME $prefix$x;}