通过命令提示符在Windows中打开带有空格的文件 [英] Opening file with spaces in Windows via Command Prompt

查看:749
本文介绍了通过命令提示符在Windows中打开带有空格的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过脚本在其默认程序中打开一个文件(特别是视频文件)。当我遇到一个带有空格的文件名,它被视为几个参数,这是不奇怪的:

  C:\folder> ;启动测试space.avi 
系统找不到文件test。但是,当我用引号将文件名引起来时:







< $ b

  C:\folder> starttest space.avi


b $ b

而不是打开其默认程序(VLC)中的文件,一个新的命令提示符窗口打开文件的目录。



打开



如何解决这个问题?

解决方案

只需离开 start ,并用双引号包围整个文件名(包括任何路径)。这在我的系统上正常工作:

  C:\>test space.avi


I want to open a file (particularly video files) in its default program via script. When I come across a file name with spaces, it is taken as several arguments which was no surprise:

  C:\folder>start test space.avi
  The system cannot find the file test.

However, when I surround the file name with quotes:

  C:\folder>start "test space.avi"

instead of opening the file in its default program (VLC), a new Command Prompt window is opened up to the directory of the file.

Opening a file without a space or quotes opens the file in VLC as expected.

How can I get around this?

解决方案

Just leave off start, and surround the full filename (including any path) with double-quotes. This works fine on my system:

C:\>"test space.avi"

这篇关于通过命令提示符在Windows中打开带有空格的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆