Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
purge_non_existing_images.sh
#3
Merci pour ta réponse
le contenu du script :
#!/bin/sh

DRYRUN=yes

if [ "$1" = "-p" ]; then
DRYRUN=no
fi

DBFILE=~/.config/darktable/library.db
TMPFILE=$(mktemp -t tmp.XXXXXXXXXX)
QUERY="select A.id,B.folder,A.filename from images as A join film_rolls as B on A.film_id = B.id"
sqlite3 $DBFILE "$QUERY" > "$TMPFILE"

echo "Removing the following non existent file(s):"

cat "$TMPFILE" | while read -r result
do
ID=$(echo "$result" | cut -f1 -d"|")
FD=$(echo "$result" | cut -f2 -d"|")
FL=$(echo "$result" | cut -f3 -d"|")
if ! [ -f "$FD/$FL" ];
then
echo " $FD/$FL with ID = $ID"

if [ $DRYRUN = no ]; then
for table in images meta_data; do
sqlite3 "$DBFILE" "delete from $table where id=$ID"
done

for table in color_labels history mask selected_images tagged_images; do
sqlite3 "$DBFILE" "delete from $table where imgid=$ID"
done
fi
fi
done
rm "$TMPFILE"


if [ $DRYRUN = no ]; then
# delete now-empty filmrolls
sqlite3 "$DBFILE" "DELETE FROM film_rolls WHERE (SELECT COUNT(A.id) FROM images AS A WHERE A.film_id=film_rolls.id)=0"
else
echo
echo Remove following now-empty filmrolls:
sqlite3 "$DBFILE" "SELECT folder FROM film_rolls WHERE (SELECT COUNT(A.id) FROM images AS A WHERE A.film_id=film_rolls.id)=0"
fi

if [ $DRYRUN = yes ]; then
echo
echo to really remove non existing images from the database call:
echo "$0" -p
fi

Une fois lancé via le menu contextuel ==> rien ne se passe

Lancé via le terminal :

brice@brice-System-Product-Name:~/Images$ chmod +x purge_non_existing_images.sh
patrice@patrice-System-Product-Name:~/Images$ ls -l
total 2672
-rw-r--r-- 1 brice patrice 2725987 mai 1 15:31 'Capture d’écran du 2019-05-01 15-31-26.png'
-rwxrwxr-x 1 brice patrice 1403 mai 8 10:13 'purge_non_existing_images (1).sh'
-rwxrwxr-x 1 brice patrice 1403 mai 8 10:17 purge_non_existing_images.sh
brice@brice-System-Product-Name:~/Images$ ./purge_non_existing_images.sh
./purge_non_existing_images.sh: 12: ./purge_non_existing_images.sh: sqlite3: not found
Removing the following non existent file(s):

Remove following now-empty filmrolls:
./purge_non_existing_images.sh: 45: ./purge_non_existing_images.sh: sqlite3: not found

to really remove non existing images from the database call:
./purge_non_existing_images.sh -p
brice@brice-System-Product-Name:~/Images$
Répondre


Messages dans ce sujet
purge_non_existing_images.sh - par PSIFWI - 08-05-19, 09:36
RE: purge_non_existing_images.sh - par PSIFWI - 08-05-19, 11:02
purge_non_existing_images.sh - par jpverrue - 08-05-19, 11:04
RE: purge_non_existing_images.sh - par jpg54 - 08-05-19, 11:15

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)