checkextensions

This commit is contained in:
Vincent Riquer 2013-04-07 03:13:10 +02:00
parent 66e4b0c1a8
commit 3d35ee02bc
2 changed files with 106 additions and 0 deletions

3
toys/README Normal file
View File

@ -0,0 +1,3 @@
checkextensions
===============
Reports files whose extension does not match the (detected) mime-type.

103
toys/checkextensions Executable file
View File

@ -0,0 +1,103 @@
#!/bin/bash
# config structures
declare -A \
destinationchannels \
destinationfat32compat \
destinationcopymime \
destinationformat \
destinationfrequency \
destinationid \
destinationloss \
destinationmaxbps \
destinationnormalize \
destinationpath \
destinationquality \
destinationrename \
destinationnoresample \
destinationrenamepath \
destinationskipmime \
|| {
echo "Check your Bash version. You need >= 4.0" >&2
exit $EBASHVERS
}
declare -r \
DOCDIR=./doc \
LIBDIR=./lib \
SHAREDIR=./share
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C
shopt -s extglob
for function in "$LIBDIR"/*/*
do
source "$function"
done
getConfig
openDatabase
getFiles
echo '
SELECT
source_files.id,
source_files.filename,
mime_types.mime_text
FROM
source_files
INNER JOIN mime_types
ON source_files.mime_type = mime_types.id
;
SELECT "AtOM:NoMoreFiles";
' >&3
while read -u4 line
do
if [[ $line == AtOM:NoMoreFiles ]]
then
break
fi
fileid=${line%%|*}
rest="${line#*|}|"
filename=${rest%%|*}
rest=${rest#*|}
mimetype=${rest%%|*}
rest=${rest#*|}
case "$mimetype" in
'audio/mpeg')
if [[ ${filename##*.} != mp3 ]]
then
echo "$filename: MP3 (.mp3)"
fi
;;
'application/ogg vorbis')
if [[ ${filename##*.} != ogg ]]
then
echo "$filename: Ogg Vorbis (.ogg)"
fi
;;
'application/ogg opus')
if [[ ${filename##*.} != opus ]]
then
echo "$filename: Opus (.opus)"
fi
;;
'audio/x-flac')
if [[ ${filename##*.} != flac ]]
then
echo "$filename: FLAC (.flac)"
fi
;;
esac
done
closeDatabase