Skip to content

Instantly share code, notes, and snippets.

@7h3rAm
Created May 18, 2017 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 7h3rAm/fcc4365c4f61276bc0970fa2c2dc3e4c to your computer and use it in GitHub Desktop.
Save 7h3rAm/fcc4365c4f61276bc0970fa2c2dc3e4c to your computer and use it in GitHub Desktop.
#!/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