#!/bin/bash
#
# Author: Erik Musick
# Date: 2011.10.13
# Version: 0.3
#
# Syntax:
# urename.sh
#
# Purpose:
# Rename files to their MD5 hash and remove all duplicates
# 20111014:IT: Added audit log to match hash with old filename for tracking
totalFiles=$(ls -1 | wc -l)
selfScript=$(md5deep -q urename.sh | cut -c -32)
auditfile='auditlog.txt'
for zFile in *; do
fileExt=$(echo $zFile | awk -F . '{if (NF>1) {print "."$NF}}')
yFile=$(md5deep -q -- "$zFile" | cut -c -32)$fileExt
echo -e "$yFile\t$zFile" >> $auditfile
mv -f -- "$zFile" "$yFile" 2> /dev/null
done
rm -rf $selfScript.sh
reducedFiles=$(ls -1 | wc -l)
echo Original File Count: $totalFiles
echo Reduced File Count: $reducedFiles
Comments
0 B
|👍
/👎