Rightclick on selected files for MD5 output on clipboard

Discuss and share scripts and script files...
Post Reply
thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Rightclick on selected files for MD5 output on clipboard

Post by thecon »

Hi guys.

I was wondering...

1) I select a bunch of files in a directory (some, not all) and I want with a right click to create a list (in the clipboard, not in a file) of their MD5 properties such as this...
MD5Sum<space>Filename, for example:

ec7eafefe4b62ecf03a6b6c3ea39695b File1.txt
61663ca0e0ce542e9e8878aec23ba9c0 File2.txt
...
etc...

How can this be done? Using a script, doing something else?

2) As an added step, can this also be done if I enable the branch view, or the find feature, so that the selection of some files could create something like this...

ec7eafefe4b62ecf03a6b6c3ea39695b Dir1\Dir2\File1.txt
61663ca0e0ce542e9e8878aec23ba9c0 Dir3\File2.txt
...
etc...

Question (2) is not as important as Question (1) though.

Thanks a lot for your help!

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Rightclick on selected files for MD5 output on clipboard

Post by highend »

In that format (<hash> <file name>) with a right click? Not possible.

You could use a right click - Context menu - To Clipboard - Name(s), Bytes, Modifed[, Version], Path, MD5

With a script you can get what you want:

Code: Select all

    $specialMode = FALSE;
    $findView = tab("get", "mode"); // 1 = Find
    $branchView = regexreplace(tab("get", "term"), "^(.*(?=\\))(.*)", "$2");
    if ($findView == 1 || regexmatches($branchView, "^\\\?\s/:?flat")) { $specialMode = TRUE; }

    $result = "";
    foreach($item, "<get SelectedItemsPathNames |>") {
        if (exists($item) == 2) { continue; }
        $result = $result . hash("md5", $item, 1) . " " . (($specialMode) ? $item : gpc($item, "file")) . <crlf>;
     }
    copytext formatlist($result, "e", <crlf>);
    status "Hash list copied to clipboard...";
It takes care for the format (only file name, file name with path) automatically
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Re: Rightclick on selected files for MD5 output on clipboard

Post by thecon »

Actually this:

"You could use a right click - Context menu - To Clipboard - Name(s), Bytes, Modifed[, Version], Path, MD5"

is quite useful.

Instead of messing with scripts, can it be done that I do...

Right click - Context menu - To Clipbard - "Name(s) MD5"

i.e. edit the useful "Name(s), Bytes, Modifed[, Version], Path, MD5" to just "Name(s) MD5" (and without commas)

?

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Rightclick on selected files for MD5 output on clipboard

Post by highend »

In that format (<hash> <file name>) with a right click? Not possible.
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Re: Rightclick on selected files for MD5 output on clipboard

Post by thecon »

Ok thank you!

This worked as a charm.

I have inserted this script in a button with multiple scripts in it...

(Right click button -> Edit -> On left click edit... ->
"Name MD5"
<script here>

"Some other name>
<some other scripts>

etc...

So that I select the files I want, then click the button, select "Name MD5" and voila, I get what I want on the clipboard.

My question is... can I assign "Name MD5" a keypress (for example <Ctrl><Alt><M>) as a shortcut without messing with the other scripts contained in this button?

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Rightclick on selected files for MD5 output on clipboard

Post by highend »

Menu - User - Manage Commands

Category: Load Script File
There you can assign a keyboard shortcut AND a label which should be called
The label is what you assigned, in this case:
Name MD5

Ofc your script must be in a file, not "inside" a button^^
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Re: Rightclick on selected files for MD5 output on clipboard

Post by thecon »

This also worked as a charm!

However, I noticed that the script does not create proper MD5's.

I need the MD5 of the contents of the file, not (perhaps) the MD5 of the filename.

And from some tests I did, the script does not produce correct MD5 of the file contents.

Any insights?

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Rightclick on selected files for MD5 output on clipboard

Post by highend »

Replace:
hash("md5", $item)

with:
hash("md5", $item, 1)
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Re: Rightclick on selected files for MD5 output on clipboard

Post by thecon »

GREAT!

Thanks a lot! bb

Post Reply