【问题标题】:"Where" command (Windows) not working when there are space characters in paths?当路径中有空格字符时,“Where”命令(Windows)不起作用?
【发布时间】:2014-03-02 21:04:00
【问题描述】:

如果我这样做:

>where notepad*.*
C:\Windows\System32\notepad.exe
C:\Windows\notepad.exe

但是当我尝试时:

where Amb*.* /r "i:\Descargas Automatizadas\"
ERROR: El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos.

抱歉,我的 Windows 是西班牙语,所以翻译应该是这样的:

ERROR: Filename, path or syntax in volume label are wrong.

我的解决方法是:

mklink /d AmberMichaels "i:\Descargas Automatizadas\"
>where Amb*.* /r AmberMichaels
h:\Temporal\Pruebas\AmberMichaels\AmbMicMeg_Amber_Michaels_-_18_and_Lost_in_Miami_sc2_Frank_Fortuna.wmv
h:\Temporal\Pruebas\AmberMichaels\AmbMicMeg_Amber_Michaels_-_ForceFantasies.com_clip1.wmv

它有效,但对于脚本问题,我认为这应该是一个问题,至少在带有空格的目录中搜索时(也就是说:如果空格字符是这里的问题,我不确定)。此外,在 Windows 7 中创建链接(mklink 命令)需要提升(管理员)。
我错了吗,也许对 where 命令有某种更新可以解决这个问题?
如果不是:编写脚本时处理此问题的最佳方法是什么?

【问题讨论】:

    标签: windows shell command-line namespaces


    【解决方案1】:
    where Amb*.* /r "i:\Descargas Automatizadas"
    

    去掉尾部反斜杠

    【讨论】:

    • 谢谢@MCND,但我想知道为什么一些简单的dir "i:\Descargas Automatizadas\"dir "i:\Descargas Automatizadas" 一样有效。这就是:我们如何定义尾部反斜杠的规则?
    猜你喜欢
    • 1970-01-01
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    相关资源
    最近更新 更多