6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[バッチ] ファイルに書き込み

Last updated at Posted at 2019-09-11

もくじ

やりたいこと

バッチファイルを使って、ファイルに文字列を書き込みたい。

やり方

echoを使う。

サンプル(上書き書き込み)

sample.bat
echo AAA> target.txt 
echo BBB> target.txt 

出力

target.txt
BBB

「AAA」は消えて、BBBで上書きされる。

注意

echo AAA> target.txt とすると、AAAの後ろにスペースが一つ入るので注意。

サンプル(追加書き込み)

sample.bat
echo AAA>> target.txt 
echo BBB>> target.txt 

出力

target.txt
AAA
BBB

「AAA」は消えず、BBBが後ろに書き込まれる。

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?