Skip to content

Instantly share code, notes, and snippets.

@binarymason
Created September 23, 2020 15:49
Show Gist options
  • Select an option

  • Save binarymason/a6f2f7a574c921323b125a3361d77b3e to your computer and use it in GitHub Desktop.

Select an option

Save binarymason/a6f2f7a574c921323b125a3361d77b3e to your computer and use it in GitHub Desktop.

Revisions

  1. binarymason created this gist Sep 23, 2020.
    23 changes: 23 additions & 0 deletions hashify.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/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