Added script to rename photos.
This commit is contained in:
parent
fe2343d4d5
commit
67b46c99c0
|
@ -0,0 +1,41 @@
|
||||||
|
#!/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
|
Loading…
Reference in New Issue