|
@@ -0,0 +1,54 @@
|
|
|
+::/** XYplorer: Generate folders checksums
|
|
|
+
|
|
|
+Creates a MD5 checksum file for the current or selected files folder.
|
|
|
+Select files or subfolders in a folder to be indexed. It will scan the selection recursively and generate a md5 checksum file in the base folder.
|
|
|
+The checksum file will be like [folder-name].md5 .
|
|
|
+It will replace the checksum file if there is already a checksum in it. The checksum also ignores any selected .md5 or .sfv files.
|
|
|
+At the end, it shows the execution log.
|
|
|
+
|
|
|
+@author rdoi
|
|
|
+@created feb/2014
|
|
|
+*/
|
|
|
+ $log="ChecksumInFolder.xys: RDoi MD5 checksum creator<crlf>-------------------------------<crlf>";
|
|
|
+ $folder=get("Path");
|
|
|
+ $log=$log."Processing '".$folder."' items...<crlf>";
|
|
|
+ if (get("CountSelected") == 0) {
|
|
|
+ $flist= folderreport("files", "r", $folder, "r", , "<crlf>");
|
|
|
+ } else {
|
|
|
+ $flist= "";
|
|
|
+ foreach($item, get("SelectedItemsPathNames"), "<crlf>") {
|
|
|
+ if (exists($item) == 2) {
|
|
|
+ $flist= $flist. folderreport("files", "r", $item, "r", , "<crlf>")."<crlf>";
|
|
|
+ } else {
|
|
|
+ $flist= $flist.$item."<crlf>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $csfile=$folder."\".regexreplace($folder,"^.*\\", "").".md5";
|
|
|
+ $template="; MD5 checksum generated by RDOI XYplorer script<crlf>; ".$folder."<crlf>";
|
|
|
+ $checksum=$template;
|
|
|
+ foreach($file, $flist, "<crlf>") {
|
|
|
+ if ($file != "") {
|
|
|
+ $rfile= replace($file,$folder."\","");
|
|
|
+ if ( regexmatches($rfile,"(\.md5|\.sfv)$") == "") {
|
|
|
+ $hash=hash("md5",$file,3);
|
|
|
+ $checksum=$checksum.$hash." *".$rfile."<crlf>";
|
|
|
+ $log=$log."+ ".$rfile." [".$hash."]<crlf>";
|
|
|
+ } else {
|
|
|
+ $log=$log."-IGNORED: Checksum file. (".$rfile.")<crlf>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($checksum == $template) {
|
|
|
+ $log=$log."No valid files selected.<crlf>=CANCELLED.";
|
|
|
+ } else {
|
|
|
+ if (exists($csfile) > 0) {
|
|
|
+ $log=$log."=REPLACED. (".$csfile.")<crlf>";
|
|
|
+ } else {
|
|
|
+ $log=$log."=CREATED. (".$csfile.")<crlf>";
|
|
|
+ }
|
|
|
+ writefile($csfile,$checksum);
|
|
|
+ }
|
|
|
+ text $log;
|