The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,227 other followers

TFS: using tf to move files

Posted by jpluimers on 2010/09/30

Recently, I had a “server binding” “status=invalid” in TFS when moving quite a bit of files from CVS to TFS.
The most problematic where getting the solution, and a webservice project correctly.

The FAQ on solution binding indicated I should fix my workspace (which is simple: just a root directory), so that was not of much help.

I tried various other things, but in the end, the easiest fix was to:

  1. rename the directories of the bad solution and project,
  2. create an empty solution
  3. create an empty ASP.NET web site project
  4. then move all of the old files to the new directory structure

Moving files around from within Visual Studio is a tedious process: you can only move one file at a time.

TF to the rescue: it allows you to call perform TFS tasks from the commandline.

Time to automate that with a little batch file.Note that in my case, that

  1. I renamed the faulty directories from “ProjectName” to “ProjectNameBad”.
  2. I executed the below batch file from “ProjectNameBad”, making sure tf was in the path.

Batch file:

@echo off

set username=domain\username
set password=p@$$W0rd

set filename=%~nx1
set sourceDirectory=%~dp1

rem strip backslash
set sourceDirectory=%sourceDirectory:~0,-1%

rem strip last 3 charachters and make relative directory
for /D %%d in (%sourceDirectory:~0,-3%) do set targetDirectory=%%~nd

echo "%filename%"
echo "%sourceDirectory%"
echo "%targetDirectory%"

tf move /login:%username%,%password% %filename% ..\%targetDirectory%\%filename%


Hope this helps a few people.


Leave a Reply

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

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: