179

I'm using Team Foundation Server 2008 (SP 1) and I need to move multiple files from one folder to another (to retain file history). In addition to Team Explorer (with SP 1) I've also got the latest TFS Power Tools (October 2008) installed (for Windows Shell integration).

Now, the problem is that I can't seem to select and move multiple files via either the shell or the Source Control Explorer window. I can move individual files (by right clicking + "Move") and I can move whole folders (same operation) but when I select multiple files (in a folder) the "Move" context item is grayed/disabled.

Does anyone know if this is possible.. and if not.. why not!?

Can anyone suggest a workaround which isn't overly complicated?

Please vote up here: https://connect.microsoft.com/VisualStudio/feedback/details/715041/support-moving-multiple-files-in-tfs-source-control-explorer and here http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2271540-allow-to-move-more-than-one-file-at-once-in-tfs-so

enter image description here

enter image description here

Nam G VU
  • 33,193
  • 69
  • 233
  • 372
RobS
  • 9,382
  • 3
  • 35
  • 63

4 Answers4

149

Use the tf.exe tool from the Visual studio commandline - it can handle wildcards:

tf.exe move <olditem> <newitem>

Example:

tf.exe move "$/My Project/V*" "$/My Project/Archive"

[EDIT] As noted in the comments: move is an alias for rename. Both commands move history.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
Kurt Schelfthout
  • 8,880
  • 1
  • 30
  • 48
  • 8
    This [other answer](http://stackoverflow.com/questions/770726/moving-multiple-files-in-tfs-source-control/5337504#5337504) is the better one here. The `move` parameter is undocumented and does not move history, while the other answer's `rename` parameter *is* documented and also moves history. – Alex Angas Sep 28 '11 at 00:05
  • 12
    For the record, it appears that in TFS 2010 the move command performs a rename which moves the history. – John Bledsoe Nov 01 '11 at 12:48
  • 10
    from the TF.EXE help: You can use the rename command or the alias move, to move a file or folder to a new location. so move and rename are the same exact thing. – Mickey Perlstein Apr 24 '12 at 13:18
  • 1
    another thing, run it from the mapped path, using command line for visual studio. otherwise it calims to not know the worspace and offers you a (useless) way to find out what workspaces you have (and then what ?? nothing.. - so run it from the mapped dir, and you'll be fine (worked for me) – Mickey Perlstein Apr 24 '12 at 13:22
  • It also works with relative paths. `cd` to the folder where you want to move files and say `tf move V* Archive`. – nalply Apr 24 '13 at 07:52
  • I use my Visual Studio Online's TFS Source Control e.g. https://namgivu.visualstudio.com. And listing the workspace by calling `tf workspaces` does not have the entry for my repository mapping. – Nam G VU Aug 14 '14 at 10:11
  • I actually found this to be very useful regarding mapping the parent folders: https://blogs.msdn.microsoft.com/buckh/2006/02/17/renaming-folders-that-are-explicitly-mapped/ – Nugs Mar 11 '18 at 04:48
  • 1
    "Cannot rename $/X/Y/Z when it has a working folder mapping assigned to it." why is this so darn difficult? just move it and let us deal with the consequences. – Christian Feb 17 '20 at 11:42
  • TF.EXE now requires the keyword `vc` for TFS version control commands. Also, `tf.exe vc move *.json .\Folder` marks files in the original folder as `Deleted` and does not include history on the newly checked-in files. – CrazyIvan1974 Apr 07 '21 at 21:16
  • The wildcard seems not work for folders, so I had to make a .bat file and list all the folders in a loop. – Eric Pitz May 04 '23 at 08:18
59

Use rename instead of move

tf.exe rename "$/PROJECT/SharedLibs/Log4Net/*.*" "$/PROJECT/SharedLibs/3rdParty/"
tf.exe rename "$/PROJECT/SharedLibs/ZipLib/*.*" "$/PROJECT/SharedLibs/3rdParty/"

Check it out the help documentation: TFS Command Line Reference

Alex Angas
  • 59,219
  • 41
  • 137
  • 210
Titwan
  • 729
  • 5
  • 6
  • Link above is throwing a HTTP500; in case it stays down, here's the TFS Command Line reference from MSDN: http://msdn.microsoft.com/en-us/library/z51z7zy0.aspx – ThisGuyKnowsCode Mar 26 '12 at 01:34
  • 12
    `move` is just an alias for `rename`, so it doesn't really matter which you use – Jeff Olson Jun 12 '12 at 18:41
  • I use my Visual Studio Online's TFS Source Control e.g. https://namgivu.visualstudio.com. And listing the workspace by calling `tf workspaces` does not have the entry for my repository mapping. – Nam G VU Aug 14 '14 at 10:10
  • "Cannot rename $/X/Y/Z when it has a working folder mapping assigned to it." Also; Wildcards _*.*_ are not allowed anymore. – Christian Feb 17 '20 at 11:43
  • 1
    "You may not specify a wildcard as a source if the target is not a folder in source control." I dont know what that means. Just move it to the name I'm pointing to. – Christian Feb 17 '20 at 11:44
41

Holan Jan has written a Visual Studio Extension which provides 'move' for multiple files within source control explorer (i.e. using a GUI) Works a treat, also has support for recent versions.

for VS2022 : https://marketplace.visualstudio.com/items?itemName=HolanJan.TFSSourceControlExplorerExtension-2022

for VS2019 : https://marketplace.visualstudio.com/items?itemName=HolanJan.TFSSourceControlExplorerExtension-2019

for VS2017 : https://marketplace.visualstudio.com/items?itemName=HolanJan.TFSSourceControlExplorerExtension-18397

for VS2015 : https://marketplace.visualstudio.com/items?itemName=HolanJan.TFSSourceControlExplorerExtension-13343

for VS2013 : https://marketplace.visualstudio.com/items?itemName=HolanJan.TFSSourceControlExplorerExtension-11508

for VS2012 : https://marketplace.visualstudio.com/items?itemName=HolanJan.TFSSourceControlExplorerExtension-8896

Under the hood it does use the same commands mentioned above but it's just a bit friendlier to use. Each of the versions listed require RTM version of Visual Studio.

Sid James
  • 529
  • 7
  • 7
  • Excellent! This is the only thing that worked for me, using VS2010: https://visualstudiogallery.msdn.microsoft.com/c6642e7f-1a58-4ff0-aef9-0322dcc2b28d – Ian Campbell Oct 24 '14 at 20:57
  • This extension is fantastic - it enables a whole bunch of additional functionality in the source control explorer, of which moving multiple files at once is only one piece. I'd highly recommend it. – SqlRyan Oct 20 '15 at 15:23
  • This is the answer. Thanks! – Frank Silano Jul 20 '20 at 14:38
-9

Stick all the files that you wish to move, under a folder and then move that folder.