Performing a recursive wildcard delete in TFS

Because I didn’t like the options for integrating SQL Server code into TFS, I wrote an application that scripts all our database objects to text files and then checks those files into TFS every night.  If there is a change in any of the files, those changes are versioned in TFS so we can go back and see when things were changed or recover old code without restoring the entire database.

But recently there was a problem with the server that my app runs on, and during the restore process, the backup process was run twice on a set of folders (at least that is my best guess) leaving thousands of duplciate files in a myriad of folders.

So for example, if there was a file called:

$DatabaseFilessqlserver1SomeDBNameSPsdbo.SomeSP.sql

then the restore process created another file called

$DatabaseFilessqlserver1SomeDBNameSPsCopy of dbo.SomeSP.sql

The problem is that my application does bulk checkins each night of all files under the DatabaseFiles folder.  I didn’t realize that the backup process had been messed up until it was too late, and those thousands of files were already checked into TFS.

So using this page to help with some of the syntax of using the TF.EXE command line too, I was able to perform a recursive wildcard delete.

In the end something like this worked just great:

tf.exe delete /recursive /noprompt "C:TFSrootDatabaseFilesCopy of*"

Notice that the wildcard is applied to all recursive folders under C:TFSrootDatabaseFiles.

Nice.

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s