Nouveaux scripts + corrections dans les anciens.

This commit is contained in:
Georges Dupéron 2010-10-13 18:32:11 +02:00
parent 3444c74c2b
commit 33de113af5
4 changed files with 72 additions and 2 deletions

13
quickhash Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
find "$@" -type f -printf "%s %p\n" | while read ab; do
sum="$(printf %8.8x "${ab%% *}")"
nom="${ab#* }"
mdsum="$(dd if="$nom" bs=512 count=1 2>/dev/null | md5sum 2>/dev/null)"
mdsum="${mdsum%% *}"
sum="$sum$mdsum"
if [ "${#sum}" != "40" ]; then
sum="0000000000000000000000000000000000000000"
fi
echo "$sum $nom"
done

View File

@ -48,7 +48,7 @@ sort | while read ab; do
if [ "$sum" != "$oldsum" ]; then
if [ -n "$orig" ]; then
for i in "${supprimable[@]}"; do
if diff -q "$orig" "$i"; then
if diff -q "$orig" "$i" > /dev/null; then
echo "rm '${i//\'/$q}'"
fi
done

57
showdoubles Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
if [ "$1" == "--help" -o "$1" == "-h" ]; then
cat <<EOF
Affiche les fichiers qui SONT des doublons, sous forme d'un script
permettant leur suppression.
Pour afficher les fichiers qui ne sont pas des doublons, utilisez
showunique.
Syntaxe : remdoubles dossier-où-chercher-les-doublons < md5sums
Exemple :
md5sums contient :
604c442629170d4bee5804b13e9a587f ./a/fichier_un
a3d0c4f97abec8c2ceaaf83020f00809 ./b/fichier_deux
a3d0c4f97abec8c2ceaaf83020f00809 ./b/fichier_trois
604c442629170d4bee5804b13e9a587f ./b/fichier_XYZ
7d4abe4e5104b71312ab56c2f341856e ./b/fichier_pas_de_doublons
Si on lance "showdoubles < md5sums", il affichera
'./a/fichier_un'
'./b/fichier_XYZ'
'./b/fichier_deux'
'./b/fichier_trois'
EOF
exit 1
fi
oldsum=""
oldnom=""
unset supprimable
first=1
q="'\\''" # escaped quote.
n=0
sort | while read ab; do
sum="${ab%% *}"
nom="${ab#* }"
if [ "$sum" != "$oldsum" ] || ! diff -q "$oldnom" "$nom" > /dev/null; then
if [ "$first" != "1" -a "$n" != 1 ]; then
echo
else
echo "$oldnom" >&2
fi
first=0
n=0
fi
if [ "$n" == 1 ]; then
echo "'${oldnom//\'/$q}'"
fi
if [ "$n" != 0 ]; then
echo "'${nom//\'/$q}'"
fi
n="$((n+1))"
oldsum="$sum"
oldnom="$nom"
done

View File

@ -35,7 +35,7 @@ sort | while read ab; do
if [ "$sum" != "$oldsum" ]; then
if [ -n "$orig" ]; then
for i in "${supprimable[@]}"; do
if diff -q "$orig" "$i"; then
if diff -q "$orig" "$i" > /dev/null; then
:
else
# Pas de clone à l'extérieur, on affiche.