::/** XYplorer: Generate folders checksums

Creates a MD5 checksum file for selected folders.
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.
The checksum file will be like [folder-name].md5 .
It will ignore the folder if there is already a checksum in it. The checksum also ignores any existing .md5 or .sfv files.

At the end, it shows the execution log.

@author rdoi
@created feb/2014
*/
		$log="ChecksumsInFolders.xys: RDoi folders MD5 checksum creator<crlf>-------------------------------<crlf>";
		foreach($folder, "<get SelectedItemsPathNames>", "<crlf>") {
			$log=$log."Processing ".$folder."...<crlf>";
			if (exists($folder) == 1) {
				$log=$log."-SKIPPED: Not a folder.<crlf>";
			} else {
				$csfile=$folder."\".regexreplace($folder,"^.*\\", "").".md5";
				if (exists($csfile) == 1) {
					$log=$log."-IGNORED: Checksum exists. (".$csfile.")<crlf>";
				} else {
					$checksum="; MD5 checksum generated by RDOI XYplorer script<crlf>; ".$folder."<crlf>";
					foreach($file, folderreport("filesrel", "r", $folder, "r", , "|"), "|") {
						$filepath=$folder."\".$file;
						if ( regexmatches($filepath,"(\.md5|\.sfv)$") == "") {
							$hash=hash("md5",$filepath,3);
							$checksum=$checksum.$hash." *".$file."<crlf>";
						} else {
							$log=$log."-IGNORED: Checksum file. (".$filepath.")<crlf>";
						}
					}
					writefile($csfile,$checksum);
					$log=$log."+CREATED. (".$csfile.")<crlf>";
				}
			}
			$log=$log."<crlf>";
		}
		text $log;