tags addtionnels
-par l’option -t -par le tableau others()
This commit is contained in:
@@ -18,3 +18,4 @@ blaireau d'europe;european badger
|
|||||||
martre;marten
|
martre;marten
|
||||||
martre des pins;pine marten
|
martre des pins;pine marten
|
||||||
bouquetin;ibex
|
bouquetin;ibex
|
||||||
|
mammifère;mammal
|
||||||
|
|||||||
|
+31
-21
@@ -4,12 +4,18 @@ red="\033[1;31m"
|
|||||||
bold="\033[1m"
|
bold="\033[1m"
|
||||||
reset="\033[0m"
|
reset="\033[0m"
|
||||||
|
|
||||||
file=$1
|
|
||||||
|
|
||||||
#t) tags+=("$OPTARG");;
|
# Tags automatically added
|
||||||
|
# You can add tags to this 4 arrays
|
||||||
|
|
||||||
|
wild=("wildlife" "wildlifephoto" "wildlifephotographer")
|
||||||
|
nat=("naturelovers" "natureshot" "naturephotography")
|
||||||
|
reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or")
|
||||||
|
others=("tag" "keu")
|
||||||
|
|
||||||
# tags -t mammifere foret animal
|
# tags -t mammifere foret animal
|
||||||
|
|
||||||
|
opt_others=false
|
||||||
opt_lens=false
|
opt_lens=false
|
||||||
opt_model=false
|
opt_model=false
|
||||||
opt_region=false
|
opt_region=false
|
||||||
@@ -33,26 +39,23 @@ do
|
|||||||
;;
|
;;
|
||||||
m) opt_model=true;;
|
m) opt_model=true;;
|
||||||
l) opt_lens=true;;
|
l) opt_lens=true;;
|
||||||
a) opt_all=false;;
|
|
||||||
*)
|
*)
|
||||||
echo "Unknow option '-$opt'" >&2
|
echo "Unknow option '-$opt'" >&2
|
||||||
exit -1;;
|
exit -1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then
|
if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then
|
||||||
opt_all=false
|
opt_all=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
l=$(echo "${tags[@]}" | sed -r 's/[^ ]+/,&/g')
|
if [ ${#others[@]} -gt 0 ] || [ ${#tags[@]} -gt 0 ]; then
|
||||||
|
opt_others=true
|
||||||
|
fi
|
||||||
|
|
||||||
# Tags automatically added
|
t=$(echo "${tags[@]}" | sed -r 's/[^ ]+/,&/g')
|
||||||
# You can add tags to this 4 arrays
|
|
||||||
|
|
||||||
wild=("wildlife" "wildlifephoto" "wildlifephotographer")
|
|
||||||
nat=("naturelovers" "natureshot" "naturephotography")
|
|
||||||
reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or")
|
|
||||||
others=("tag" "keu")
|
|
||||||
|
|
||||||
|
|
||||||
#trans fr:en -b "renard"
|
#trans fr:en -b "renard"
|
||||||
@@ -102,7 +105,6 @@ exif=$(exiftool -Canon -s -Keywords "$file")
|
|||||||
|
|
||||||
# keywords
|
# keywords
|
||||||
k=$(echo "$exif" | sed -n '/^Keywords/p' | awk -F":" '{print $2}' | sed 's/^ *//g')
|
k=$(echo "$exif" | sed -n '/^Keywords/p' | awk -F":" '{print $2}' | sed 's/^ *//g')
|
||||||
[ "$l" != "" ] && k="$k $l"
|
|
||||||
|
|
||||||
if [ -z "$k" ]; then
|
if [ -z "$k" ]; then
|
||||||
echo -e "${bold}${red}No Keywords found !${reset}"
|
echo -e "${bold}${red}No Keywords found !${reset}"
|
||||||
@@ -225,6 +227,7 @@ END_COMMENT
|
|||||||
|
|
||||||
|
|
||||||
echo "tags: ${tags[@]}"
|
echo "tags: ${tags[@]}"
|
||||||
|
echo "others: ${others[@]}"
|
||||||
echo "file: $file"
|
echo "file: $file"
|
||||||
echo "wildlife: $opt_wildlife"
|
echo "wildlife: $opt_wildlife"
|
||||||
echo "nature: $opt_nature"
|
echo "nature: $opt_nature"
|
||||||
@@ -239,31 +242,26 @@ if [ $opt_all = false ]; then
|
|||||||
if [ $opt_wildlife = false ]; then
|
if [ $opt_wildlife = false ]; then
|
||||||
wildlife_flickr=""
|
wildlife_flickr=""
|
||||||
wildlife_insta=""
|
wildlife_insta=""
|
||||||
echo "pas de wildlife !"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $opt_nature = false ]; then
|
if [ $opt_nature = false ]; then
|
||||||
nature_flickr=""
|
nature_flickr=""
|
||||||
nature_insta=""
|
nature_insta=""
|
||||||
echo "pas de nature !"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $opt_region = false ]; then
|
if [ $opt_region = false ]; then
|
||||||
region_flickr=""
|
region_flickr=""
|
||||||
region_insta=""
|
region_insta=""
|
||||||
echo "pas de region !"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $opt_lens = false ]; then
|
if [ $opt_lens = false ]; then
|
||||||
lens_flickr=""
|
lens_flickr=""
|
||||||
lens_insta=""
|
lens_insta=""
|
||||||
echo "pas de lens !"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $opt_model = false ]; then
|
if [ $opt_model = false ]; then
|
||||||
model_flickr=""
|
model_flickr=""
|
||||||
model_insta=""
|
model_insta=""
|
||||||
echo "pas de model !"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -271,16 +269,27 @@ fi
|
|||||||
keywords_flickr="$keyword_flickr$model_flickr$lens_flickr$wildlife_flickr$nature_flickr$region_flickr"
|
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)}')
|
keywords_insta=$(echo "$keyword_insta$model_insta$lens_insta$wildlife_insta$nature_insta$region_insta" | awk '{print tolower($0)}')
|
||||||
|
|
||||||
if [ ${#others[@]} -gt 0 ]; then
|
if [ $opt_others = true ]; then
|
||||||
|
|
||||||
|
# insert tags added with option -t to others's tag array
|
||||||
|
others+=(`echo $t | tr ',' ' '`)
|
||||||
|
|
||||||
for i in "${others[@]}"
|
for i in "${others[@]}"
|
||||||
do
|
do
|
||||||
if [[ "$i" = *" "* ]]; then
|
if [[ ${dico["$i"]} ]] ; then
|
||||||
others_flickr+="\"${i}\" "
|
o_en=${dico["$i"]}
|
||||||
else
|
else
|
||||||
others_flickr+="${i} "
|
o_en=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$o_en" ]; then
|
||||||
|
[[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} "
|
||||||
|
[[ "$o_en" = *" "* ]] && others_flickr+="\"${o_en}\" " || others_flickr+="${o_en} "
|
||||||
|
others_insta+="#${i// /} #${o_en// /} "
|
||||||
|
else
|
||||||
|
[[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} "
|
||||||
|
others_insta+="#${i// /} "
|
||||||
fi
|
fi
|
||||||
others_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
|
|
||||||
done
|
done
|
||||||
keywords_flickr+="$others_flickr"
|
keywords_flickr+="$others_flickr"
|
||||||
keywords_insta+="$others_insta"
|
keywords_insta+="$others_insta"
|
||||||
@@ -293,6 +302,7 @@ echo "$keywords_insta"
|
|||||||
echo
|
echo
|
||||||
END_COMMENT
|
END_COMMENT
|
||||||
|
|
||||||
|
|
||||||
# suppress accent (bug in macos) => add sed => suppress punctuation too
|
# suppress accent (bug in macos) => add sed => suppress punctuation too
|
||||||
# https://stackoverflow.com/questions/806199/how-to-fix-weird-issue-with-iconv-on-mac-os-x
|
# https://stackoverflow.com/questions/806199/how-to-fix-weird-issue-with-iconv-on-mac-os-x
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user