42 lines
822 B
Bash
Executable File
42 lines
822 B
Bash
Executable File
#!/bin/bash
|
|
|
|
function checkJhead()
|
|
{
|
|
local result
|
|
local check=$(which ant)
|
|
if [[ "$check" =~ ^/.* ]]; then
|
|
echo "jhead requirement OK"
|
|
result=1
|
|
else
|
|
echo "jhead requirement MISSING"
|
|
result=0
|
|
fi
|
|
return $result
|
|
}
|
|
|
|
# main
|
|
|
|
# Lowercase extension.
|
|
uppercaseCount=$(find -maxdepth 1 -name '*.JPG' | wc -l)
|
|
if [[ $uppercaseCount > 0 ]]; then
|
|
rename 's/JPG/jpg/' *.JPG
|
|
fi
|
|
echo ".JPG -> .jpg: $uppercaseCount"
|
|
|
|
# Rename.
|
|
checkJhead
|
|
if [[ $? == 1 ]]; then
|
|
count=0
|
|
for filename in $(ls *.jpg); do
|
|
#echo "==== $filename"
|
|
if [[ $(jhead $filename | grep Date) =~ ^Date.* ]]; then
|
|
#echo "yop $filename"
|
|
jhead -n%Y%m%d-%H%M%S "$filename"
|
|
let "count+=1"
|
|
fi
|
|
done
|
|
echo "Renamed: $count"
|
|
else
|
|
echo "KO"
|
|
fi
|