IsraelTorres icon

urename.sh

IsraelTorres | PRO | 10/14/11 08:15:51 PM UTC | 0 ⭐ | 385 👁️ | Never ⏰ | []
Bash |

730 B

|

None

|

0 👍

/

0 👎

#!/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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎