1

I often use the "Command Window" in Visual Studio to quickly open a file by name, for instance by typing open main.c.

However what doesn't seem to work is open *.xyz, the intent being to open any files in the solution with some extension xyz.

Is there a quick and easy way from the Command Window to open multiple files at once based on a pattern?

DuckMaestro
  • 15,232
  • 11
  • 67
  • 85
  • "Quick Open File" plugin(http://visualstudiogallery.msdn.microsoft.com/3eb2f230-2728-4d5f-b448-4c0b64154da7) lets you quickly find files within the solution using wildcards in the search, but it doesn't let you open multiple files at once. – Alireza Maddah May 25 '11 at 05:29

3 Answers3

3

I couldn't get the command window to work. Use a text editor or a script to make a list of files like this:

"full path 1" "full path 2"

Ctrl+o and paste the string into the open file dialog.

Hans
  • 2,230
  • 23
  • 23
  • 2
    This only seems to work for a few files, because the open dialog only accepts a finite amount of characters. –  Jan 16 '12 at 22:48
1

Here is a solution using Visual Commander which is a VS add-on. It uses file paths from the clipboard. I tend to drop to a command line use a dir /s/b *.?? or another more complicated solution using powershell to generate these file paths.

using EnvDTE;
using EnvDTE80;
using System;
using System.Windows.Forms;
using System.IO;

public class C : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
    {
        if(Clipboard.ContainsText(TextDataFormat.Text))
        {
            string[] files = Clipboard.GetText(TextDataFormat.Text).Replace("\r","").Split(new string[] {"\n"}, StringSplitOptions.RemoveEmptyEntries);
            foreach(string f in files)
            {
                try 
                {
                    FileInfo fileInfo = new FileInfo(f);
                    if(fileInfo.Exists)
                    {
                        DTE.ItemOperations.OpenFile(f, EnvDTE.Constants.vsViewKindPrimary);
                    }
                }
                catch{ }
            }
        }
    }
}
user1529413
  • 458
  • 8
  • 19
-1

you can use find command to do that:

$find . -name "*.xyz" -exec open {} \;
  • How a linux command line helps with opening files in Visual Studio (which doesn't available on Linux)? What is `open` command anyway? My linux terminal doesn't recognize it. – Yehezkel B. Nov 03 '21 at 10:15