【问题标题】:How to search / open a file type without knowing the file name如何在不知道文件名的情况下搜索/打开文件类型
【发布时间】:2019-11-06 16:25:00
【问题描述】:

我正在尝试为我的cmder 编写一个别名以快速打开某个文件。通常我导航到我想要的目录并输入“代码”。在 vscode 中打开项目。但是有些项目在 Visual Studio 中,所以我不能使用“代码”。我正在尝试编写一个别名,当键入时会找到以“.sln”结尾的文件,该文件以 Visual Studio 项目结尾,然后打开它。

我尝试将dir /b *.sln 管道化为start,例如:

start | dir /b *.sln

但这只是为cmder打开了一个新的空标签,我不知道为什么。

有没有办法管这个?或者可能有另一种方法可以做到这一点? (也许“开始”的参数可以让我执行我不知道的操作)。

【问题讨论】:

  • 这可能很容易,甚至非常容易。 assoc .sln 的输出是什么?

标签: windows cmd command-line command-prompt


【解决方案1】:

那么,可以试试这个...

在命令行中:

for /f ^tokens^=* %i in ('""%__APPDIR__%where.exe" /r . "*.sln""')do start "" "%~i"

或者,在 bat/cmd 文件中:

for /f ^tokens^=* %%i in ('""%__APPDIR__%where.exe" /r . "*.sln""')do start "" "%%~i"

有关 for、where 和 start 命令的更多信息/帮助,请尝试:

>"%temp%\help_cmds.txt" (for /? & where /? & start /?) & "%temp%\help_cmds.txt"

此命令将从命令中获取帮助,并将保存在将打开的 txt 文件中..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-04
    • 2017-09-16
    • 1970-01-01
    • 1970-01-01
    • 2012-02-21
    相关资源
    最近更新 更多