os/shell/ RandomSnippets1


# rename .jpg's to STEM_HASH.jpg where HASH is the first 12 chars from sha256sum and STEM is common to all renamed flies
# useful for e.g. photos downloaded from Facebook where the original name is e.g. 398766541_72341234123430_7100001111222233330_n.jpg
hashren() { 
  local P="$1"; 
  [ -z "$P" ] && P=$(basename "$PWD"); 
  for s in *.jpg; do 
    a="$(sha256sum "$s" | cut -c-12)"; 
    mv -vn "$s" "${P}_${a}.jpg"; 
  done; 
}