2015-11-18 49 views
0

運行下面批處理文件中的目錄名稱空間/(/ F 「delims =」 不工作)

@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

+3

'嘗試在%%˚F' – jeb

回答

1

嘗試使用:( 「!targetlocation *」)

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

@SchaDee。我確實需要delayedexpansion其他原因(http://stackoverflow.com/questions/33351455/batch-file-deal-with-ampersand-in-folder-name) – BuckTurgidson

+0

行!但那不是你的問題,你是否嘗試了我的答案? – SachaDee

相關問題