Skip to content

Instantly share code, notes, and snippets.

@chasemc
Created April 15, 2021 12:20
Show Gist options
  • Save chasemc/304eee5b9dd17bf3b4a80ae94bc0d06e to your computer and use it in GitHub Desktop.
Save chasemc/304eee5b9dd17bf3b4a80ae94bc0d06e to your computer and use it in GitHub Desktop.
Rename files by md5 and chosen extension
#!/usr/bin/bash
# $1 is the file(s') name to find and hash
# $2 is the extension to be given to each renamed file
find $1 -print0 | xargs -0 md5sum |
while read -r newname oldname; do
mv -v "$oldname" "$newname".$2
done
@chasemc
Copy link
Author

chasemc commented Apr 15, 2021

In a directory containing "some_data.tsv":

bash ./md5_as_filename.sh "some_data.tsv" "descriptiveextension"

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