如何将有空间的目录路径传递给Windows shell?
我正在使用 IEcapt.exe 来捕获网站快照。 问题是,它无法处理有空间的路径目录。像这样:
c:\program files\
有什么方法可以传递这样的目录以使其工作吗?
I am using IEcapt.exe to capture website snapshot.
The problem is, it cannot handle path directory that have space. Like this:
c:\program files\
Is there any way how I can pass directory like this to make it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通常只需双引号 Windows 路径即可工作:
如果这确实不起作用,您可能可以使用 8.3 文件名,或者,如果是程序文件,则为
%programfiles%
变量。Usually just double-quoting windows paths will work:
If that really doesn't work, you might be able to get away with using the 8.3 filename or, in the case of program files, the
%programfiles%
variable.参见小二郎的回复。但是,如果您确实无法使用空格或长文件名,那么这里有一个技巧,因为您调用的工具不支持这些。我曾经遇到过使用 MS 的一些构建工具的情况。
由于短文件名不允许包含空格,因此我们可以使用:
... 其中
I
是当前子(或脚本)的参数编号。由于此功能仅适用于编号参数,因此您可能必须使用间接寻址,例如:See the reply from kojiro. However, here is a trick if you really aren't able to use blank spaces or long file names, because the tools you call do not support that. I've had this case with some build tools from MS.
Since short filenames are not allowed to contain blank spaces, we can use:
... where
I
is the number of the parameter to the current sub (or the script). Since this is a feature that only works on numbered parameters, you may have to use an indirection, such as:小次郎的回答有效。但就我而言,我需要
而不是
第二个示例使用
echo
命令在屏幕上打印整个路径,但我需要第一个示例将其正确传递到我的脚本。kojiro's answer works. But in my case I needed to
instead of
The second example works with
echo
command to print the entire path on screen for example, but I needed the first example to pass it correctly to my script.我希望我可以使用上述方法之一。然而,我只能使用旧的 DOS 短名称。
超过 8 个字符的 DOS 文件名被~文件号截断。例如,C:\Program Files 将为 c:\progra~1,C:\Program Files (x86) 将为 c:\progra~2。
您可以使用
DIR /X
命令查找文件的短名称。我特别需要这个来从 Atom 文本编辑器中启动 ConEmu。
我从 Sachleen 的答案 此处 得出了这种方法
I wish that I could have used one of the methods above. However, I could only use the old DOS short names.
DOS file names longer than 8 characters were truncated with ~number for files. For example, C:\Program Files would be c:\progra~1, and C:\Program Files (x86) would be c:\progra~2.
You can find the short names for files using
DIR /X
command.I needed this specifically to launch ConEmu from within Atom text editor.
I derived this approach from Sachleen's Answer HERE