How can I load the contents of a text file into a batch file variable?

前端 未结 6 1733
小鲜肉
小鲜肉 2020-12-07 19:12

I need to be able to load the entire contents of a text file and load it into a variable for further processing.

How can I do that?


Here\'s what I di

6条回答
  •  难免孤独
    2020-12-07 19:50

    If your set command supports the /p switch, then you can pipe input that way.

    set /p VAR1=

    The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty.

    This has the added benefit of working for un-registered file types (which the accepted answer does not).

提交回复
热议问题