Skip to content

Instantly share code, notes, and snippets.

@sashka
Created April 11, 2015 22:10
Show Gist options
  • Save sashka/661d2bcedb644ff6af60 to your computer and use it in GitHub Desktop.
Save sashka/661d2bcedb644ff6af60 to your computer and use it in GitHub Desktop.
Rename file with the SHA1 of its content.
#!/bin/bash
find . -type f -name '*.m[p4][a3]' -exec bash -c 'fn=$(basename "$0"); ext=$(echo "${fn##*.}" | tr '[A-Z]' '[a-z]'); mv "$0" "$(sha1sum "$0" | cut -d" " -f1).$ext"' {} \;
@shizeeg
Copy link

shizeeg commented Oct 24, 2017

the description is misleading. This script renames all the *.mp3, *.mpa & *.mp4 files in current directory with sha1sum of their contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment