rename files
This commit is contained in:
parent
3d35ee02bc
commit
e09fefb429
@ -1,3 +1,8 @@
|
|||||||
checkextensions
|
checkextensions
|
||||||
===============
|
===============
|
||||||
Reports files whose extension does not match the (detected) mime-type.
|
Reports files whose extension does not match the (detected) mime-type.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-u: update source directory
|
||||||
|
-r: rename files
|
||||||
|
-n: (with -r): show what would be done.
|
||||||
|
|||||||
@ -41,11 +41,20 @@ do
|
|||||||
source "$function"
|
source "$function"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
while getopts 'urn' opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
u) update=1 ;;
|
||||||
|
r) rename=1 ;;
|
||||||
|
n) pretend=1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
getFiles
|
(( update )) && getFiles
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
SELECT
|
SELECT
|
||||||
@ -59,6 +68,14 @@ echo '
|
|||||||
;
|
;
|
||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
' >&3
|
' >&3
|
||||||
|
renameFile() {
|
||||||
|
echo $'\t'"${filename%.*}$extension"
|
||||||
|
if ! (( pretend ))
|
||||||
|
then
|
||||||
|
mv "$sourcepath/$filename" "$sourcepath/${filename%.*}$extension"
|
||||||
|
Update source_files filename "${filename%.*}$extension"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
while read -u4 line
|
while read -u4 line
|
||||||
do
|
do
|
||||||
@ -76,25 +93,33 @@ do
|
|||||||
'audio/mpeg')
|
'audio/mpeg')
|
||||||
if [[ ${filename##*.} != mp3 ]]
|
if [[ ${filename##*.} != mp3 ]]
|
||||||
then
|
then
|
||||||
echo "$filename: MP3 (.mp3)"
|
extension=.mp3
|
||||||
|
echo "$filename: MP3 ($extension)"
|
||||||
|
(( rename )) && renameFile
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
'application/ogg vorbis')
|
'application/ogg vorbis')
|
||||||
if [[ ${filename##*.} != ogg ]]
|
if [[ ${filename##*.} != ogg ]]
|
||||||
then
|
then
|
||||||
echo "$filename: Ogg Vorbis (.ogg)"
|
extension=.ogg
|
||||||
|
echo "$filename: Ogg Vorbis ($extension)"
|
||||||
|
(( rename )) && renameFile
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
'application/ogg opus')
|
'application/ogg opus')
|
||||||
if [[ ${filename##*.} != opus ]]
|
if [[ ${filename##*.} != opus ]]
|
||||||
then
|
then
|
||||||
echo "$filename: Opus (.opus)"
|
extension=.opus
|
||||||
|
echo "$filename: Opus ($extension)"
|
||||||
|
(( rename )) && renameFile
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
'audio/x-flac')
|
'audio/x-flac')
|
||||||
if [[ ${filename##*.} != flac ]]
|
if [[ ${filename##*.} != flac ]]
|
||||||
then
|
then
|
||||||
echo "$filename: FLAC (.flac)"
|
extension=.flac
|
||||||
|
echo "$filename: FLAC ($extension)"
|
||||||
|
(( rename )) && renameFile
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user