Skip to content

Instantly share code, notes, and snippets.

@theratman
Last active June 18, 2023 20:04
Show Gist options
  • Save theratman/6b934314e1600b68869c864c1f8faf0c to your computer and use it in GitHub Desktop.
Save theratman/6b934314e1600b68869c864c1f8faf0c to your computer and use it in GitHub Desktop.
Rename files to md5 sum plus extension
#!/bin/bash
# For Mac OS X version (md5)
MD="md5 -r"
# For Linux version (md5sum)
MD="md5sum"
for i in ./*; do
mv "${i}" "./$($MD "$i" | awk '{print $1}').${i##*.}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment