循环的批处理文件,在目录名称中带有空格/(/ f" delims ="不工作)

时间:2015-11-18 15:04:07

标签: batch-file whitespace directory

下面运行
@echo off
setlocal enableDelayedExpansion
set "targetlocation=C:\Users\myself\Documents\FOLDER WITH BLANK SPACES\"
for %%f in (!targetlocation!*) do echo %%f
pause

打印:

C:\Users\myself\Documents\FOLDER
WITH
BLANK
Press any key to continue . . .

我尝试实现以下更改,但无法运行(请参阅下面的源代码)

for f/ "delim=" %%f in (!targetlocation!*) do echo %%f

batch file for loop with spaces in dir name

1 个答案:

答案 0 :(得分:1)

尝试:

set targetlocation="C:\Users\myself\Documents\FOLDER WITH BLANK SPACES\"