gestion-de-commission/Convention photos/lowext

31 lines
696 B
Bash
Executable File

#!/bin/bash
checkcommand()
{
local result
local command="$1"
which "$command" 1>/dev/null 2>&1
if [[ $? == 0 ]]; then
echo "$command requirement OK"
result=1
else
echo "$command requirement MISSING"
result=0
fi
return $result
}
# main
if [[ "$1" == "-h" ]]; then
echo "The lowext command lowercases JPG file extensions in the current directory not recursively."
else
checkcommand rename
if [[ $? == 1 ]]; then
uppercaseCount=$(find -maxdepth 1 -name '*.JPG' | wc -l)
if [[ $uppercaseCount > 0 ]]; then
rename 's/JPG/jpg/' *.JPG
fi
echo ".JPG -> .jpg: $uppercaseCount"
fi
fi