Batch : read lines from a file having spaces in its path

后端 未结 3 658
逝去的感伤
逝去的感伤 2021-01-12 11:15

To read lines from a file, in a batch file, you do :

for /f %%a in (myfile.txt) do (
    :: do stuff...
)

Now suppose you file is in

3条回答
  •  一向
    一向 (楼主)
    2021-01-12 12:08

    Just sharing the below code, hoping that somebody will get benefited.

    The below code take both the path having spaces and also if the read lines has spaces, it wont cause any issue of the characters after space is missing;

    FOR /f "tokens=* delims=," %%a in ('type "C:\Progrem File\My Program"') do ( echo %%a )

提交回复
热议问题