Merge branch 'toys'
* toys: cleandestinations: find/remove unwanted files from destinations
This commit is contained in:
commit
b7ae6bb5ad
@ -6,3 +6,11 @@ Options:
|
|||||||
-u: update source directory
|
-u: update source directory
|
||||||
-r: rename files
|
-r: rename files
|
||||||
-n: (with -r): show what would be done.
|
-n: (with -r): show what would be done.
|
||||||
|
|
||||||
|
cleandestinations
|
||||||
|
=================
|
||||||
|
Checks destinations for possibly unwanted files (e.g. files not created by
|
||||||
|
AtOM).
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-r: remove unwanted files.
|
||||||
|
|||||||
78
toys/cleandestinations
Executable file
78
toys/cleandestinations
Executable file
@ -0,0 +1,78 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
while getopts 'rD' opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
r) remove=1 ;;
|
||||||
|
D) (( debug++ )) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
getConfig
|
||||||
|
|
||||||
|
openDatabase
|
||||||
|
|
||||||
|
checkwanted() {
|
||||||
|
Select id <<<"filename = $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
for destination in "${!destinationpath[@]}"
|
||||||
|
do
|
||||||
|
echo -ne "\rScanning destination $destination... \033[K"
|
||||||
|
while read filename
|
||||||
|
do
|
||||||
|
if ! Select destination_files id \
|
||||||
|
>/dev/null \
|
||||||
|
<<<"filename = $filename"
|
||||||
|
then
|
||||||
|
echo -e $'\r'"$filename\033[K"
|
||||||
|
(( remove )) && rm -f "$filename"
|
||||||
|
echo -n "Scanning destination $destination... "
|
||||||
|
fi
|
||||||
|
progressSpin
|
||||||
|
done < <(find "${destinationpath["$destination"]}" -type f)
|
||||||
|
done
|
||||||
|
echo -en "\r\033[K"
|
||||||
|
|
||||||
|
closeDatabase
|
||||||
Loading…
x
Reference in New Issue
Block a user