Page 1 of 1
Folder Hashing
Posted: 01 Mar 2012 10:08
by bluerouter
Hi all,
First time poster to the forum, and hoping that someone can point me in the right direction.
I hope that I am not trying to re-invent the wheel, and that I have missed something obvious?
As part of my role I need to create hash values (MD5) of all the files within folders, and output this to a txt file. I have been using
http://corz.org/windows/software/checksum/ but would rather create a script in XYplorer.
As a newbie, can this be done? Or has someone already created this. I have trawled the forums but havent come across anything yet.
Thanks in advance for any help.
Re: Folder Hashing
Posted: 01 Mar 2012 10:21
by highend
You tried "hash" as the search term?
http://www.xyplorer.com/xyfc/viewtopic. ... hilit=hash
One way to do this with a script.
And instead of using <get selecteditemspathnames |> and text $result;
look into the help file for folderreport and writefile.
Re: Folder Hashing
Posted: 01 Mar 2012 10:53
by bluerouter
Thasnks will take a look at that. I see that it is CRC32, I need to use MD5, guess it's a case of replacing the variable.
New to the scripting, so need to take some time to read, but I need to get this done quickly.
Thanks for the info.
Re: Folder Hashing
Posted: 01 Mar 2012 13:03
by highend
Code: Select all
// Create hashes for all files in current folder (recursively)
$result = "";
$folders = folderreport("files", "r", , "r", , "|");
foreach($file, $folders, "|") {
if($file == "") { break; }
$checksum = hash("md5", $file, 1);
$result = $result . $file . " Checksum: " . $checksum . <crlf>;
}
writefile("<curpath>\checksum.log", $result);
Uses all files (recursively) from the current folder and writes the output to
a file named checksum.log
Re: Folder Hashing
Posted: 01 Mar 2012 13:21
by bluerouter
Thanks, looks good.
When I get 5 minutes I just need to ouput this to a txt file rather than pop-up.
Appreciate the assist for first time user.
Re: Folder Hashing
Posted: 01 Mar 2012 13:27
by highend
Edited my last post for a file instead a popup.
Re: Folder Hashing
Posted: 01 Mar 2012 13:39
by bluerouter
Damn you're quick!
Thanks for the help, much appreciated
Re: Folder Hashing
Posted: 01 Mar 2012 16:04
by j_c_hallgren
bluerouter wrote:Damn you're quick!
Thanks for the help, much appreciated
Hi and welcome to the XY forums!
That's what we pride ourselves on this forum: Being very helpful very quickly!
It's not always that speedy as it depends on time of day but it's highly unusual to not get any reply for more than a day at the very most.
Re: Folder Hashing
Posted: 01 Mar 2012 16:31
by bluerouter
Thanks for that.
Great piece of software, I must admit I haven't used it fully yet, still getting to grips with what it can do.
Going to spend some time learning the scripting side.

Re: Folder Hashing
Posted: 01 Mar 2012 18:10
by admin
Just a quick note from my holiday resort.

I don't think this line is necessary or good within the loop:
folderreport() never returns empty elements IF it returns anything (which it does not when the folder is empty, or if certain flags are passed which filter the return). So I'd rather check for empty folders like this:
Code: Select all
// Create hashes for all files in current folder (recursively)
$result = "";
$folders = folderreport("files", "r", , "r", , "|");
if (strlen($folders)) {
foreach($file, $folders, "|") {
$checksum = hash("md5", $file, 1);
$result = $result . $file . " Checksum: " . $checksum . <crlf>;
}
writefile("<curpath>\checksum.log", $result);
} else {
msg "Folder empty."
}