如何将目录与空间合并到Windows批处理脚本中,单引号中的双引号



简单的问题(Windows Batch),但很难找到特定的答案。

我如何合并:

DIR "T:Some DirectoryAnother Dir" /S /B /A-D

进入这个:

FOR /F %%i IN ('DIR "T:Some DirectoryAnother Dir" /S /B /A-D ^| FINDSTR /EVIL ".jpg .JPG .mp4 .MP4"') DO

我在目录的引号上遇到问题 - 命令正在寻找" t: soming",因为该目录在太空中被拆分。

尝试逃脱 ^,双引号,三引号等。没有效果...

问题是我猜想的双引号...

谢谢,

您需要告诉For循环以忽略其默认的Whitespace定界符。

您可以使用:

FOR /F "DELIMS=" %%A IN ('
    DIR/B/S/A-D-S-L "T:Some DirectoryAnother Dir"^|FindStr/EVIL ".jpg .mp4"
') DO …

或:

FOR /F "DELIMS=" %%A IN ('DIR/B/S/A-D-S-L "T:Some DirectoryAnother Dir"'
) DO IF /I NOT "%%~xA"==".jpg" IF /I NOT "%%~nxA"==".mp4" (…

最新更新