Add parameters

-w wildlife tags
-n nature tags
-r region tags
-m model tags
-l lens tags
-t additionnal tags
-f file
This commit is contained in:
2022-08-21 07:19:42 +02:00
parent 130260dbc7
commit f13dacb45c

View File

@@ -6,6 +6,45 @@ reset="\033[0m"
file=$1
#t) tags+=("$OPTARG");;
# tags -t mammifere foret animal
opt_lens=false
opt_model=false
opt_region=false
opt_nature=false
opt_wildlife=false
opt_all=true
unset -v tags
while getopts "wnrf:t:ml" opt
do
case $opt in
w) opt_wildlife=true;;
n) opt_nature=true;;
r) opt_region=true;;
f) file="${OPTARG}";;
t) tags=("$OPTARG")
until [[ $(eval "echo \${$OPTIND}") =~ ^-.* ]] || [ -z $(eval "echo \${$OPTIND}") ]; do
tags+=($(eval "echo \${$OPTIND}"))
OPTIND=$((OPTIND + 1))
done
;;
m) opt_model=true;;
l) opt_lens=true;;
a) opt_all=false;;
*)
echo "Unknow option '-$opt'" >&2
exit -1;;
esac
done
if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then
opt_all=false
fi
l=$(echo "${tags[@]}" | sed -r 's/[^ ]+/,&/g')
# Tags automatically added
# You can add tags to this 4 arrays
@@ -50,7 +89,7 @@ if [ -f ./keywords.csv ]; then
x="${en[$j]}"
dico+=( ["$i"]="$x" )
((j=j+1))
done
done
fi
@@ -63,7 +102,7 @@ exif=$(exiftool -Canon -s -Keywords "$file")
# keywords
k=$(echo "$exif" | sed -n '/^Keywords/p' | awk -F":" '{print $2}' | sed 's/^ *//g')
# _vert_, accouplement, brocard, capreolus capreolus, chevrette, chevreuil, rut
[ "$l" != "" ] && k="$k $l"
if [ -z "$k" ]; then
echo -e "${bold}${red}No Keywords found !${reset}"
@@ -163,11 +202,10 @@ do
done
: <<'END_COMMENT'
echo "Model flickr: $model_flickr"
echo "Model insta: $model_insta"
echo
: <<'END_COMMENT'
echo "Keywords flickr: $keyword_flickr"
echo "Keywords insta: $keyword_insta"
echo
@@ -185,6 +223,51 @@ echo "Region insta: $region_insta"
echo
END_COMMENT
echo "tags: ${tags[@]}"
echo "file: $file"
echo "wildlife: $opt_wildlife"
echo "nature: $opt_nature"
echo "region: $opt_region"
echo "model: $opt_model"
echo "lens: $opt_lens"
echo "all: $opt_all"
echo
if [ $opt_all = false ]; then
if [ $opt_wildlife = false ]; then
wildlife_flickr=""
wildlife_insta=""
echo "pas de wildlife !"
fi
if [ $opt_nature = false ]; then
nature_flickr=""
nature_insta=""
echo "pas de nature !"
fi
if [ $opt_region = false ]; then
region_flickr=""
region_insta=""
echo "pas de region !"
fi
if [ $opt_lens = false ]; then
lens_flickr=""
lens_insta=""
echo "pas de lens !"
fi
if [ $opt_model = false ]; then
model_flickr=""
model_insta=""
echo "pas de model !"
fi
fi
keywords_flickr="$keyword_flickr$model_flickr$lens_flickr$wildlife_flickr$nature_flickr$region_flickr"
keywords_insta=$(echo "$keyword_insta$model_insta$lens_insta$wildlife_insta$nature_insta$region_insta" | awk '{print tolower($0)}')