[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 pd1 于 2023-2-7 18:15 编辑

保存为A.bat后运行,会生成一个B.bat和hash.bat(这个就是保存的一个hash表),然后你运行你的改名,最后运行B.bat恢复试试。
  1. <# :
  2. @echo off
  3. powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0' |Out-String|Invoke-Expression"
  4. pause
  5. #>
  6. $bat=@'
  7. <# :
  8. @echo off
  9. powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0' |Out-String|Invoke-Expression"
  10. pause
  11. #>
  12. $ss=ConvertFrom-Json -InputObject (Get-Content .\hash.bat)
  13. dir -s|Where-Object{$_.Extension -ne ".bat" -and $_ -is [System.IO.FileInfo]}|ForEach-Object{$h=(Get-FileHash -Path $_.FullName -Algorithm MD5).hash;ren $_.FullName $ss.$h.Replace((Split-Path $ss.$h).ToString()+"\","")}
  14. '@
  15. $bat|Out-File -Append -Encoding default -FilePath B.bat
  16. $s="{"
  17. dir -s|Where-Object{$_.Extension -ne ".bat" -and $_ -is [System.IO.FileInfo]}|ForEach-Object{$s+='"'+(Get-FileHash -Path $_.FUllName -Algorithm MD5).hash+'":"'+$_.FullName.replace("\", "\\")+'",'}
  18. $s=$s.Substring(0,$s.Length-1)+"}"
  19. $s|Out-File -Append -FilePath hash.bat
复制代码

TOP

返回列表