Monday, July 5, 2010

Bash: Delete recursive duplicated folders

for i in `find /home/directory -type d`
do

cd $i
mydir=$(pwd|rev|awk -F \/ '{print $1}'|rev)
directory="$i/$mydir/$mydir"
dirtorm="$i/$mydir"
if [ -d "$directory" ]; then
echo "=======>$i"
rm -f -r $dirtorm
echo $directory
fi

done

No comments: