2010-07-05 45 views
1

我試圖通過批處理文件在txt文件的所有行上運行命令。我努力逃避for循環的IN()子句中的字符。BAT文件的IN子句中的空間循環

這工作:

for /F %%i IN (C:\test.txt) DO echo %%i 

這些不:

for /F %%i IN (C:\Documents and Settings\user\Desktop\test.txt) DO echo %%i 
for /F %%i IN ("C:\Documents and Settings\user\Desktop\test.txt") DO echo %%i 
for /F %%i IN ('C:\Documents and Settings\user\Desktop\test.txt') DO echo %%i 

任何想法如何獲得CMD來註冊完整路徑? Thanks-

喬納森

回答

0

嘗試for commandusebackq選項。

for /F usebackq %%i IN ('C:\Documents and Settings\user\Desktop\test.txt') DO echo %%i 
+0

是的,它做到了。 for/F usebackq %% i IN(「C:\ Documents and Settings \ user \ Desktop \ test.txt」)DO echo %% i – Jonathan 2010-07-05 23:24:21