[批次] 用for delims切逗號 tokens的問題

看板EzHotKey作者時間4年前 (2020/05/09 18:39), 4年前編輯推噓1(101)
留言2則, 1人參與, 4年前最新討論串1/1
指令是這樣: For /f "delims=, tokens=1" %a in (.\test.txt) do @if exist %a echo %a text.txt的內容類似這樣: HashMyFiles.cfg,b64024e1b47393606d62c64e7546ae56,,,,,,C:\Dropbox\ HashMyFiles.chm,ee90eae5744b57ef24e8d4f2f42de4b7,,,,,,C:\Dropbox\ 輸出的內容會是這樣: HashMyFiles.cfg HashMyFiles.chm 但用: For /f "delims=, tokens=2" %a in (.\test.txt) do @if exist %a echo %a 這樣的時候就不會有內容 但用: For /f "delims=, tokens=3" %a in (.\test.txt) do @if exist %a echo %a 又可以正確得到: C:\Dropbox\ C:\Dropbox\ 想請問為什麼tokens=2的時候反而無法顯示? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 218.187.80.162 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/EzHotKey/M.1589020743.A.9F5.html

05/09 19:19, 4年前 , 1F
tokens=2 就是第2個就是b64...56和ee9...b7,
05/09 19:19, 1F

05/09 19:20, 4年前 , 2F
它們不存在於檔案系統吧! not exist 所以就 not echo
05/09 19:20, 2F
喔原來如此,我還以為可以用來解析字串... PS:我找到我想寫的寫法了,謝謝 For /f "delims=, tokens=2" %a in (.\test.txt) do ECHO %a>>temp.txt ※ 編輯: kslman (218.187.80.162 臺灣), 05/09/2020 21:11:38
文章代碼(AID): #1UjeX7dr (EzHotKey)