batファイル テキストファイルを読み込むサンプル

環境
Windows 10 home 64bit

構文
for /f “delims=" %%s in (.\ファイル名)
batファイルからテキストファイルを読み込みます

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@echo off
for /f "delims=" %%s in (.\messageA.txt) do (
echo %%s
)
@echo off for /f "delims=" %%s in (.\messageA.txt) do ( echo %%s )
@echo off

for /f "delims=" %%s in (.\messageA.txt) do (
  echo %%s
)

実行結果
C:\2023\bat>test.bat
arkgame
study
skill
become

batch

Posted by arkgame