Windows Server 2003 R2 Enterprise を実行しているサーバーがあり、ディレクトリごとに 1 KB のテキスト ファイルが 50,000 ~ 250,000 個あります。ファイル名は連続しており (MLLP000001.rcv、MLLP000002.rcv など)、同一のファイルは連続しています。後続のファイルが異なると、別の同一のファイルを受け取ることはないと予想できます。
次のことを行うスクリプトが必要ですが、どこから始めればよいかわかりません。
for each file in the target directory index 'i'
{
for each file in the target directory index 'j' = i+1
{
compare the hash values of files i and j
if the hashes are identical
delete file j
if the hashes differ
set i = j // to skip past the files that are now deleted
break
}
}
DOS バッチ スクリプトを試してみましたが、これは非常に面倒です。内側のループから抜け出すことができません。また、外側のループにはディレクトリ内のファイルのリストがあるため、ループ自体が失敗しますが、そのリストは常に変化しています。私の知る限り、VBScript にはハッシュ関数がありません。