我的忠實路徑遍歷方法不再有效 - 它將空格視爲分隔符。我需要進行批量編程已經有一段時間了。
使用FOR
循環時,唯一允許分隔符的是FOR /F
選項。
我不想創建一個包含路徑的臨時文件,希望做一些象下面這樣:在Windows中使用FOR進行遍歷路徑變量
C:\Users>for /f "delims=;" %i in %path% do echo %i C:\Program was unexpected at this time. C:\Users>for /f "delims=;" %i in (%path%) do echo %i \Common was unexpected at this time. C:\Users>for /f "delims=;" %i in 'foo;bar' do echo %i 'foo was unexpected at this time.
的稍微改進版本請不要將您選擇的解決方案插入到問題中!我做了[回滾](http://stackoverflow.com/revisions/38913232/4)。接受答案清楚地表明哪個解決方案對你最合適。謝謝! – aschipfl