Clean code

This commit is contained in:
2023-07-21 09:58:05 +02:00
parent 07230ac0cd
commit 85668bb29f

View File

@@ -224,7 +224,7 @@ fi
echo -e "\n${greenbold}keywords2insta${reset} v2.0"
echo -e "\n${bold}Reading $file exif...${reset}"
#exif=$(exiftool -Canon -s -Keywords "$file")
# The exiftool application exits with a status of 0 on success, or 1 if an
# error occurred, or 2 if all files failed the -if condition (for any of
# the commands if -execute was used).
@@ -237,13 +237,6 @@ exif=$(exiftool -j "$file")
# the commands if -execute was used).
# exif
#echo "$exif"
#if (jq -e '.[] | has("Make")' <<< "$exif"); then
# make=$(echo "$exif" | jq -j '.[] | .Make')
#else
# make="z"
#fi
#make=$(echo "$exif" | jq -e '.[] | has("Make") | .Make')
@@ -291,16 +284,12 @@ k=$(echo "$exif" | jq --compact-output --raw-output '.[] | .Keywords[]?' | tr "\
if [ -z "$k" ]; then
echo -e "\n${bold}${red}No Keywords found !${reset}"
echo "Quit."
#exit 5
echo
fi
IFS="," read -a key <<< "$k"
#echo "key:${key[@]}_"
#echo "dico:${dico[@]}_"
for i in "${key[@]}"
do
@@ -308,22 +297,11 @@ do
# @ bouton d'or@
# xargs: unterminated quote
#ii=$(echo "$i" | xargs -0) # trim $i
#ii=$(echo "$i" | sed 's/ *$//g')
ii="$i"
trim ii
#trim i
#echo "i:$i"
#echo "ii:$ii"
if [[ ! "$ii" =~ ^_ ]]; then
#echo "ii: $ii"
#echo ${dico["$ii"]}
if [[ ${dico["$ii"]} ]] ; then
k_en=${dico["$ii"]}
else
@@ -332,8 +310,6 @@ do
k_fr="$ii"
#echo "k_fr:$k_fr"
#echo "k_en:$k_en"
if [ -n "$k_en" ]; then
[[ "$k_fr" = *" "* ]] && keyword_flickr+="\"${k_fr}\" " || keyword_flickr+="${k_fr} "
@@ -344,8 +320,6 @@ do
keyword_insta+="#${k_fr// /} "
fi
#echo "keyword_insta:$keyword_insta"
#echo "keyword_flickr:$keyword_flickr"
fi
done
@@ -411,7 +385,6 @@ fi
for i in "${mod[@]}"
do
#model+="${i} "
if [[ "$i" = *" "* ]]; then
model_flickr+="\"${i}\" "
else
@@ -420,8 +393,6 @@ do
model_insta+="#${i// /} " # supprime tous les espaces et ajoute le #
done
#echo "model_flickr: $model_flickr"
#echo "model_insta: $model_insta"
#lens
@@ -474,9 +445,6 @@ done
lens_flickr="\"${l}\" "
lens_insta="$(echo "$l" | sed 's/ //g' | sed -r 's/[^ ]+/#&/g') "
#echo "lens_flickr: $lens_flickr"
#echo "lens_insta: $lens_insta"
for i in "${wild[@]}"
do
@@ -485,7 +453,6 @@ do
else
wildlife_flickr+="${i} "
fi
#wildlife_insta+="#"$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g')" "
wildlife_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
done
@@ -623,7 +590,6 @@ if ! command -v gawk &> /dev/null; then
echo -e " - brew install gawk"
echo -e ""
else
#keywords_flickr=$(echo "$keywords_flickr" | gawk -v RS="[ \n]" -v ORS=" " '!($0 in a){print;a[$0]}')
keywords_insta=$(echo "$keywords_insta" | gawk -v RS="[ \n]" -v ORS=" " '!($0 in a){print;a[$0]}')
fi