Created
May 8, 2016 11:20
-
-
Save dyama/bcba199d26c5324a08243054aeddd759 to your computer and use it in GitHub Desktop.
md5name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# coding: utf-8 | |
if [ $# -gt 0 ]; then | |
for file in “$@” | |
do | |
if [ -f “$file” -a -s “$file” ]; then | |
# Get file extention | |
ext=`basename “$file” | sed ‘s/^.*\.\(.*\)$/\1/gi’`; | |
if [ “$file” == $ext ] ; then | |
ext=””; | |
else | |
ext=”.$ext”; | |
fi | |
# Make new file name | |
nfile=`dirname “$file”`/`md5sum “$file” | cut -c -32`$ext; | |
# echo $file to $nfile | |
mv “$file” $nfile | |
fi | |
done | |
else | |
cat <<EOUSG | |
md5name – Rename the file with md5sum string. | |
By dyama=members.fsf.org 2010. | |
Usage: | |
$0 File […] | |
EOUSG | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment