0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【WinMerge】コマンドラインで差分のみ出力

Posted at

(基本)WinMergeをコマンドで起動

前準備

比較用のサンプルテキスト用意します。

sampleA.txt
AAA
BBB
sampleB.txt
AAA
BB*
CCC

コマンドプロンプトを起動し、以下のように入力する。

comandWinMerge.bat
"C:\Program Files\WinMerge\WinMergeU.exe" "sampleA.txt" "sampleB.txt" /minimize /noninteractive -or "CompareResult.html"
コマンド 意味
C:\Program Files\WinMerge\WinMergeU.exe WinMerge 起動
(※パスは個人で異なります)
sampleA.txt 比較対象1
(※パスは個人で異なります)
sampleB.txt 比較対象2
(※パスは個人で異なります)
\minimize 最小画面で起動
\noninteractive 処理終了と同時にアプリを閉じる
-or レポートのファイルパス
CompareResult.html レポートの出力先
(※パスは個人で異なります)

実行

コマンドプロンプトでバッチ名を入力し実行
>comandWinMerge.bat

結果確認

出力された CompareResult.html を開く
image.png

無事にレポートの出力に成功しました。
ただ、差分がない「AAA」も出力されてますね。
では、本題に移りましょう。

差分のみ出力するコマンド

前準備

先ほど作成したバッチに、-cfg "Settings/DiffContextV2=0" を追加

comandWinMerge.bat
"C:\Program Files\WinMerge\WinMergeU.exe" "sampleA.txt" "sampleB.txt" /minimize /noninteractive -cfg "Settings/DiffContextV2=0" -or "CompareResult.html"

実行

コマンドプロンプトでバッチ名を入力し実行
>comandWinMerge.bat

結果確認

出力された CompareResult.html を開く
image.png

「AAA」は無く、差分のみ出力されましたね!

補足

  • -cfg
    コマンドラインから設定情報(※)を指定できます。

  • "Settings/DiffContextV2=0"
    diffコンテキストを0行に設定
    diffコンテキスト:差分があった前後の行を指定した行数だけ表示できる

※他の設定情報を確認してみる

編集 > 設定 をクリック。
image.png

ウィンドウが開くので、エクスポートをクリック。
エクスポート先を指定したらエクスポートを実行。
image.png

エクスポートされた設定情報を確認。見ての通りめちゃめちゃあります。
「-cfg 〇〇〇=〇」のような表記でここの設定をいじれると思うので、カスタマイズしてお試しあれ。
image.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?