Skip to content

Instantly share code, notes, and snippets.

@binarymason
Created September 23, 2020 15:49
Show Gist options
  • Save binarymason/a6f2f7a574c921323b125a3361d77b3e to your computer and use it in GitHub Desktop.
Save binarymason/a6f2f7a574c921323b125a3361d77b3e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
src=$(basename $1)
dest="hashed/${src}"
mkdir -p "$dest"
for fullfile in ${src}/*; do
filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"
md5=$(md5sum "$fullfile" | awk '{print $1}' | head -c 8)
echo "$fullfile -> $dest/$md5.$extension"
cp "$fullfile" "$dest/$md5.$extension"
done
mkdir -p processed
mv "$src" "processed/$src"
echo done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment