34 lines
1020 B
Bash
Executable File
34 lines
1020 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
DANCE_VIDEOS_DB="${HOME}/Documents/.DanceVideos/db.sqlite"
|
|
RAW_VIDEOS_DIR="${HOME}/Documents/.DanceVideos/raw/"
|
|
|
|
check_registered_files_exist() {
|
|
sqlite3 -separator '|' "$DANCE_VIDEOS_DB" "
|
|
SELECT file_name, raw_file, mp4_file FROM videos;
|
|
" | while IFS='|' read -r file_name raw_file mp4_file; do
|
|
# Sauter l'en-tête
|
|
if [[ "$file_name" == "file_name" ]]; then
|
|
continue
|
|
fi
|
|
|
|
# Ignorer les lignes vides
|
|
if [[ ! -e "$raw_file" || ! -e "$mp4_file" ]]; then
|
|
echo "$raw_file KO : $mp4_file" >&2
|
|
else
|
|
echo "$raw_file OK"
|
|
fi
|
|
|
|
done
|
|
}
|
|
|
|
check_files_are_registered() {
|
|
for f in $(find "$RAW_VIDEOS_DIR" -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.mov" \) -print); do
|
|
if [[ -z $(sqlite3 "$DANCE_VIDEOS_DB" "SELECT 1 FROM VIDEOS WHERE RAW_FILE='$f';") ]]; then
|
|
echo "$f not registered" >&2
|
|
# open $f
|
|
fi
|
|
done
|
|
}
|
|
|
|
check_files_are_registered |