Score:0

Print hashes when a file or a folder is drag'n'droped to terminal

tv flag

I need a way to quickly see hashes of singular files and of all files in a given folder. Drag'n'drop should work great, but in lxqt you can't drag'n'drop to scripts or even desktop entries.

I have a script that opens the terminal and receives one file at a time and prints its hash. I need it to be able to recognize a folder too and to hash all files in it. The problem is I don't know bash.

#!/bin/bash
while IFS=$' \t\r\n' read -d '' -p "Drag'n'drop file to hash: " -rsn 1 str &&
    [ "$str" ];do
    while IFS= read -d '' -rsn 1 -t .02 char
    do str+="$char"
    done
    if [ "$str" ] ;then
        read -a req <<<"$str"
        echo ''
        md5sum $req
        echo ''
    fi
  done
waltinator avatar
it flag
Read `man -k inotify`.
Score:0
tv flag

This recognizes a file and a folder, including files in nested folders and paths with spaces. As a bonus, shows info in the terminal name instead of printing it every time.

#!/bin/bash
echo -ne "\033]0;Drag & drop file or folder\007"
while IFS=$'\t\r\n' read -d '' -rsn 1 str && [ "$str" ]; do
    while IFS= read -d '' -rsn 1 -t .02 char; do
        str+="$char"
    done
    if [ "$str" ]; then
        find "$str" -type f -exec md5sum {} \;
    fi
done
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.