Created
May 18, 2017 19:22
-
-
Save 7h3rAm/fcc4365c4f61276bc0970fa2c2dc3e4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SAMPLESDIR="$1" | |
TMPFILE="/tmp/sha256sum" | |
EXT="sample" | |
MOVE=false | |
sha256sum "$SAMPLESDIR"/* >"$TMPFILE" | |
while read line; do | |
SHA256=$(echo $line | tr -s " " | cut -d" " -f1) | |
FILENAME=$(echo $line | tr -s " " | cut -d" " -f2) | |
if [ "$MOVE" == "true" ]; then | |
mv -f "$FILENAME" "${SAMPLESDIR}/${SHA256}.$EXT" 1>/dev/null 2>&1 | |
else | |
cp -f "$FILENAME" "${SAMPLESDIR}/${SHA256}.$EXT" 1>/dev/null 2>&1 | |
fi | |
done <"$TMPFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment