Code in Command prompt doesn't work in batch file
问题 The code below does what I want when I execute it in the command prompt but not when I put it in a .bat file and try to execute it: for /f %a in ('dir /b *.csv') do for /f "tokens=*" %b in (%a) do echo %b,%a >> all.csv What am I missing. Also is there a way to have it do exactly what it does without displaying every step in the loop in the command prompt window. Excuse me I am a newbie! 回答1: In batch files - as opposed to at the command prompt - for variables require two %% signs, e.g. %%a .