在将文件写入磁盘之前预览哈希

问题描述

我编写了代码以散列某些文件,并用文件夹中的扩展名分隔。最后,将生成一个哈希文件。在将文件写入磁盘之前,是否可以预览哈希“#MP3_DIR_ $ hash.txt”?我提出这个问题,是为了节省对磁盘的读写,并加快脚本的速度。

$directory = (Get-ChildItem -Recurse -Directory).FullName
Foreach ($path in $directory) {
  If (!(Test-Path -Path "$path\#MP3_DIR_*.txt")) {
    $array = @()
    Get-ChildItem -Path "$path\*.mp3" | Foreach {((Get-filehash "$_" -Algorithm MD5).Hash)} | ForEach-Object { $array += "$_" }
  }
  If (!($array -eq $null)) {
    $array = $array | Where-Object {$_}
    $array = $array | Sort

    $hashfile = (Get-filehash -Algorithm MD5 -InputStream ([System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($array)))).Hash
    
    $array | Set-Content -LiteralPath "$path\#MP3_DIR_$hashfile.txt"
  }
}

变量“ $ hashfile”不能输出与写为“ $ path#MP3_DIR_ $ hashfile.txt”的文件相同的哈希值。在将文件写入光盘之前如何预览此文件的哈希?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)