Today one of my colleagues needed to move some files into a sub-folder in the project’s workspace in TFS 2008 Source Control.
It seems with Team Explorer, you can move individual files by right-clicking the file and choosing Move. However, you can’t do this with multiple files selected! You can move a whole folder, but that moves the entire folder and not just the files in it, so it doesn’t work to a sub-folder within that folder.
I suggested checking out the files, moving them in the workspace on his local machine and then checking them back in. I was thinking that TFS would be aware that these files have now moved and would handle this accordingly. WRONG!
We could move them and then add them as new files in the “new” location, but this would mean they lose all the history for the files.
It turns out, you can’t move files around in Source Control using Team Explorer, but you can by using the tf.exe command-line utility provided (usually found in: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE). You’ll need to add the correct path for your computer using the DOS Set command like this:
SET PATH=%PATH%;"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE"
To do this you use the rename function of the utility and provide the new location for the files, like this:
- Get the latest copy of the files that you want to move, using Team Explorer.
- Open a Command Prompt and change to the drive and path where the files you want to move currently exist.
- Move the files to the new location using the rename function of the tf.exe command-line utility like this:
tf rename <files> <new_location> /lock:checkin
The following example will move all files into a sub-folder of the current folder called Video Thumbs:
tf rename *.* "Video Thumbs" /lock:checkin
If you now look at the Source Control new & old folders in the workspace and you should see your files have been moved. All you have to do now is check in the changes and the files are moved!
WARNING: Using a wildcard like *.* will also move folders!

