MD5 File Repair Tool v.1.0

Discuss and share scripts and script files...
Post Reply
waqu
Posts: 17
Joined: 04 Jan 2015 05:58
Location: Russia/Saint-Petersburg
Contact:

MD5 File Repair Tool v.1.0

Post by waqu »

Restores the location and names of files by md5 hash and verifies MD5 checksums.

Code: Select all

"MD5 Tool: Add info about the file"
 foreach($token,<get SelectedItemsPathNames |>){
  $tag=tagitems("tag",,$token);
  $curbase=getpathcomponent($token,"base");
  $md5=hash("md5",$token,3);
  $regexmatches=regexmatches(readfile("<xydrive>\Records\FileInfo.txt"),"$md5.*",<crlf>);
  $md5comp=gettoken($regexmatches,1,"|");
  if($md5!=$md5comp){
   writefile("<xydrive>\Records\FileInfo.txt","$md5|$curbase|$token|$tag|<crlf>",a);
  }
 }
 sound "%SystemRoot%\media\tada.wav";
 status "Done";

"MD5 Tool: Repairing paths of files"
 foreach($token,<get SelectedItemsPathNames |>){
  $md5=hash("md5","$token",3);
  $readfile=readfile("<xydrive>\Records\FileInfo.txt");
  $regex=regexmatches("$readfile","$md5.*",<crlf>);
  $regexmd5=regexmatches("$readfile","$md5",<crlf>);
  $path=gettoken("$regex",3,"|");
  $tag=gettoken("$regex",4,"|");
  if($md5==$regexmd5){
   copyitem "$token","$path";
   tag "$tag","$path",1,1;
  }
 }
 sound "%SystemRoot%\media\tada.wav";
 status "Done";

"MD5 Tool: Check MD5 sum"
 foreach($token,<get SelectedItemsPathNames |>){
  $md5=hash("md5","$token",3);
  $readfile=readfile("<xydrive>\Records\FileInfo.txt");
  $regex=regexmatches("$readfile","$md5.*",<crlf>);
  $regexmd5=regexmatches("$readfile","$md5",<crlf>);
  if($md5==$regexmd5){
   $a++;
   $md5ok="$md5 OK $regex<crlf>$md5ok";
  }
  if($md5!=$regexmd5){
   $b++;
   $md5bad="$md5 BAD $token<crlf>$md5bad";
  }
 }
 sound "%SystemRoot%\media\tada.wav";
 status "Done";
 $replace=replacelist("$md5ok<crlf>$md5bad<crlf>$a OK $b Not Found",'$md5ok,$md5bad,$a OK , $b Not Found',,",");
 text "$replace";
Usage:
1. First you have to add information about checksum and path of the selected files to a text file.
* .You can restore the structure and file paths of the surviving information about the hashes and the paths in a text file.
* .You can verify the checksum of a file of previously saved information.

Post Reply