ChecksumsInFolders.xys 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ::/** XYplorer: Generate folders checksums
  2. Creates a MD5 checksum file for selected folders.
  3. Just select some folders in any panel and run. It will scan all subfiles/subfolders within and generate a md5 checksum file in each folder.
  4. The checksum file will be like [folder-name].md5 .
  5. It will ignore the folder if there is already a checksum in it. The checksum also ignores any existing .md5 or .sfv files.
  6. At the end, it shows the execution log.
  7. @author rdoi
  8. @created feb/2014
  9. */
  10. $log="ChecksumsInFolders.xys: RDoi folders MD5 checksum creator<crlf>-------------------------------<crlf>";
  11. foreach($folder, "<get SelectedItemsPathNames>", "<crlf>") {
  12. $log=$log."Processing ".$folder."...<crlf>";
  13. if (exists($folder) == 1) {
  14. $log=$log."-SKIPPED: Not a folder.<crlf>";
  15. } else {
  16. $csfile=$folder."\".regexreplace($folder,"^.*\\", "").".md5";
  17. if (exists($csfile) == 1) {
  18. $log=$log."-IGNORED: Checksum exists. (".$csfile.")<crlf>";
  19. } else {
  20. $checksum="; MD5 checksum generated by RDOI XYplorer script<crlf>; ".$folder."<crlf>";
  21. foreach($file, folderreport("filesrel", "r", $folder, "r", , "|"), "|") {
  22. $filepath=$folder."\".$file;
  23. if ( regexmatches($filepath,"(\.md5|\.sfv)$") == "") {
  24. $hash=hash("md5",$filepath,3);
  25. $checksum=$checksum.$hash." *".$file."<crlf>";
  26. } else {
  27. $log=$log."-IGNORED: Checksum file. (".$filepath.")<crlf>";
  28. }
  29. }
  30. writefile($csfile,$checksum);
  31. $log=$log."+CREATED. (".$csfile.")<crlf>";
  32. }
  33. }
  34. $log=$log."<crlf>";
  35. }
  36. text $log;