0

How to destroy all the TFS files and folders?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
mithun_daa
  • 4,334
  • 5
  • 38
  • 50

1 Answers1

2

Use the following Powershell + TF.exe script to destroy all the deleted files and folders in TFS

$tfsServer = Get-TfsServer -name http://YOURTFSSERVER:PORT    
$destroyList = get-tfschilditem -item $/Root/ -server $tfsServer -Deleted -recurse | Where {$_.DeletionId -ne 0} 
foreach($item in $destroyList)
{
    $itemPath = '"' + $item.ServerItem + ";X" + $item.DeletionId + '"'
    tf destroy $itemPath /i /startcleanup
}
mithun_daa
  • 4,334
  • 5
  • 38
  • 50
  • For reference, destroying should only be used as a last resort. Even if you've deleted files and folders you may want to refer to them in the future to understand the history of your code base. Destroying goes aginst the spirit of version control. I don't know the circumstances in this instance but I would be _very_ wary of using this generic script. I've been using TFS since it was in beta and I've only wanted to destroy on a handful of occasions. This is usually when I've messed something up (e.g. Branched from the wrong parent) – James Reed Jan 17 '13 at 17:19
  • Totally agree @JamesReed. We have a very unique branching strategy and we have thousands and thousands of folders that get deleted which we never have the need to go back to. Hence the "destroys". – mithun_daa Jan 17 '13 at 19:44
  • 1
    A good case for destroying: Someone accidentally added a file to TFS that does not need to be source controlled, like an assembly, package, or installer. – xr280xr May 19 '15 at 20:40