Skip to content

Instantly share code, notes, and snippets.

@yoosefi
Created September 1, 2016 00:25
Show Gist options
  • Save yoosefi/72f43cff4a645f6eff1bc793350b6a9f to your computer and use it in GitHub Desktop.
Save yoosefi/72f43cff4a645f6eff1bc793350b6a9f to your computer and use it in GitHub Desktop.
Rename a file to its md5 checksum, keeping the extension
#!/bin/bash
# renames all input files to their md5 checksum, keeping the extension.
# this can be used as a nemo script.
for each in "$@"; do
NAME=$(basename "${each}")
EXT="${NAME#*.}"
DIR=$(dirname "${each}")
MD5=($(md5sum "${each}"))
mv "${each}" "${DIR}/${MD5}.${EXT}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment