概要
ディレクトリAとディレクトリBを、バイナリレベルで一致していることをチェックしたい場合は、バイナリdiffをとるのも1つの手ですが、Microsoftのfciv.exeを使うと、より早くチェックできます。
fcivはファイルのハッシュ値を取るユーティリティプログラムで、ディレクトリAとディレクトリBの中にあるファイルハッシュ値を比較することで、一致チェックができます。
fciv.exeにはオプションがいろいろあるのですが、ディレクトリAとディレクトリBの完全一致チェックを行うための手順は、次のようになります。
- .fciv.exeでディレクトリAでファイルハッシュを取得し、XMLファイル(dirA.xmlとします)に出力します。
- fciv.exeでディレクトリBのファイルハッシュをdirA.xmlと比較します。
具体例
- ディレクトリAをc:\workとします。
- ディレクトリBをx:\testとします。
- 各ディレクトリにa.txtを配置して、比較する例です。
手順1 dirA.xmlを作成
PS > .\fciv.exe c:\work -bp c:\work -r -sha1 -xml dirA.xml |
// File Checksum Integrity Verifier version 2.05. |
Start Time: 07/05/2013 at 12h03 '31' ' |
Error loading XML document. |
End Time..: 07/05/2013 at 12h03 '31' ' |
Errors have been reported to fciv.err |
手順2 比較
PS > .\fciv.exe -v x:\test -bp x:\test -sha1 -xml dirA.xml |
結果: 差異がない場合の表示
// File Checksum Integrity Verifier version 2.05. |
Could not create the registry key. |
Starting checksums verification : 07/05/2013 at 12h05'53 |
All files verified successfully |
End Verification : 07/05/2013 at 12h05'53 |
結果: a.txtに差異があった場合の表示
// File Checksum Integrity Verifier version 2.05. |
Could not create the registry key. |
Starting checksums verification : 07/05/2013 at 12h06'11 |
Hash is : a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 |
It should be : 5d39e1aedb99cf0a706a5d0dfd73c773bf7a528f |
End Verification : 07/05/2013 at 12h06'11 |
結果: a.txtが存在しない場合の表示
// File Checksum Integrity Verifier version 2.05. |
Could not create the registry key. |
Starting checksums verification : 07/05/2013 at 12h07'31 |
Unable to Hash file a.txt |
Error msg : 指定されたファイルが見つかりません。 |
End Verification : 07/05/2013 at 12h07'31 |
fciv.exeの詳細はこちら→http://support.microsoft.com/default.aspx?scid=kb;en-us;841290
あなたのテーマが魅力的だった。