Saturday, June 18, 2016

Removing Duplicate Files

#!/usr/bin/env bash 

old_var="zzz"
var="xxx"
[ -n "${1}" ] && CMD="echo Dryrun: "
while read a; do 
var="$(basename "${a}")"
[ "${var}" == "${old_var}" ] && ${CMD} rm -v "${a}" || old_var="${var}"
done < <(find . -type f | rev | sort -t'/' -k 1 | rev) 
Note: This uses names only, to make it robust add md5sums.

No comments:

Post a Comment