Add_sclipco.sh.
This is the master command for personified source, copyright, license for images on wikibooks (sclipco) and include en_sclipco.inc or fr_sclipco.inc
TEXTDOMAIN=add_slipco
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
 . gettext.sh
 if [ "$0" = "./add-sclipco" ]; then echo "add-sclipco : Version "$VERSION; fi
 if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
 else echo $"$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
 fi
 Projectdir=$Workdir/books/$1
 Pagesclipco="$Projectdir/$1.sclipco"
 echo $Pagesclipco
 source $Bindir/scli.inc
 cat $Projectdir/$1.scli > $Pagesclipco
 if [ "$2" = "--t" ]
 then 
 pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt
 if [ "$Site" = "fr.wikibooks.org" ]; then source $Localdir/fr_sclipco.inc.sh
 else source $Localdir/en_sclipco.inc.sh
 fi
 else
 if [ "$Site" = "fr.wikibooks.org" ]; then source $Bindir/fr_sclipco.inc
 else source $Bindir/en_sclipco.inc
 fi
 fi
en_slipco.inc.sh.
TEXTDOMAIN=en_sclipco.inc
TEXTDOMAINDIR="/usr/share/locale"
Version=211008
 cd $Projectdir
 if [ "$2" = "--t" ]
 then 
 echo "Projectdir = $Projectdir"
 echo "en_sclipco version = $Version"
 fi
 Pagesclipco=$Projectdir/$1.sclipco
 while read pjline
 do
 if [ $pjline != $1 ]
 then
 cd $Projectdir/$pjline
 cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
 cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
 cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
 cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://$Site | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
 cat $Projectdir/$pjline/$pjline.images | sed "s/$Site/commons.wikimedia.org/g"| sed "s/Fichier/File/g" > $Projectdir/$pjline/$pjline.commonsimages
 wget -P $Projectdir/$pjline -r -linf -k -p -E -i $Projectdir/$pjline/$pjline.commonsimages
 cp $Projectdir/$pjline/commons.wikimedia.org/wiki/*.html $Projectdir/$pjline/. 
 echo -n "" > commonshtml.doublons 
 while read pictline
 do
 #echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
 echo $pictline | awk -F"/" '{ print $NF".html"}' » commonshtml.doublons
 echo -n "" > commonshtml.list
 END { for ( i = 1 ; i <= NR ; i=i+2 ) {
 print memfile[i] » "commonshtml.list"
 # print "Fin"
 } ' commonshtml.doublons
 done < $Projectdir/$pjline/$pjline.commonsimages
 echo "Article : $pjline<br \>" » $Pagesclipco
 echo "Article : $pjline"
 while read htmlline
 do
 echo ""
 echo ""
 echo "$(gettext ' ---- line read = $htmlline --- ')"
 echo ""
 mkd -pw '**' $htmlline $htmlline.tmp
 cat $htmlline.tmp | tr ',' '\n' > $htmlline.co.str 
 echo -n "$(gettext ' Illustration : ')" > $htmlline.co.title
 cat $htmlline.co.str | grep wgTitle | cut -d '"' -f4 » $htmlline.co.title
 cat $htmlline.co.title » $Pagesclipco 
 cat $htmlline.co.title
 echo -n ", "$(gettext ' source : ')"https://commons.wikimedia.org/wiki/" > $htmlline.co.source
 echo -n $htmlline | sed "s/.html//g" | sed "s/.str//g" » $htmlline.co.source
 if [ "$Site" = "fr.wikibooks.org" ]; then echo "?uselang=fr" » $htmlline.co.source
 elif [ "$Site" = "en.wikibooks.org" ]; then echo "?uselang=en" » $htmlline.co.source
 else echo
 fi
 cat $htmlline.co.source » $Pagesclipco
 cat $htmlline.co.source
 echo -n "$(gettext ' , "license : ')" " > $htmlline.co.license
 cat $htmlline.co.str | grep licensetpl_short | sed "s/<td>//g" | sed "s/<span class//g" | sed "s/<\/span>//g" | sed "s/style=\"display:none;\"//g" | tr '=' '\n' | grep licensetpl_short | awk -F">" '{print $NF}' » $htmlline.co.license
 cat $htmlline.co.license » $Pagesclipco
 cat $htmlline.co.license
 echo -n " > tmp
 echo -n "$(gettext ' , "author(s) : " ')" > $htmlline.co.author
 cat $htmlline.co.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp
 read Tmp < tmp
 #T
 echo "Tmp = $Tmp"
 if [ "$Tmp" = "" ]
 #T then echo "tmp empty"
 then echo "-" > tmp 
 fi
 #T echo $Tmp | cut -d '-' -f2 | sed "s/\.\ /%/g" | cut -d '%' -f1 
 cat tmp » $htmlline.co.auteur
 cat $htmlline.co.auteur » $Pagesclipco
 cat $htmlline.co.auteur
 echo "" » $Pagesclipco
 done < commonshtml.list
 fi
 done < $Projectdir/$1.pj
 echo "</div>" » $Pagesclipco
 echo "$(gettext ' ')" » $Pagesclipco
exit 0
fr_slipco.inc.sh.
Version=210709
 cd $Projectdir
 if [ "$2" = "--t" ]
 then 
 echo "Projectdir = $Projectdir"
 echo "fr_sclipco version = $Version"
 fi
 Pagesclipco=$Projectdir/$1.sclipco
 while read pjline
 do
 if [ $pjline != $1 ]
 then
 cd $Projectdir/$pjline
 cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
 cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
 cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
 cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://$Site | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
 cat $Projectdir/$pjline/$pjline.images | sed "s/$Site/commons.wikimedia.org/g"| sed "s/Fichier/File/g" > $Projectdir/$pjline/$pjline.commonsimages
 wget -P $Projectdir/$pjline -r -linf -k -p -E -i $Projectdir/$pjline/$pjline.commonsimages
 cp $Projectdir/$pjline/commons.wikimedia.org/wiki/*.html $Projectdir/$pjline/.
 echo -n "" > commonshtml.doublons 
 while read pictline
 do
 #echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
 echo $pictline | awk -F"/" '{ print $NF".html"}' » commonshtml.doublons
 echo -n "" > commonshtml.list
 END { for ( i = 1 ; i <= NR ; i=i+2 ) {
 print memfile[i] » "commonshtml.list"
 # print "Fin"
 } ' commonshtml.doublons 
 done < $Projectdir/$pjline/$pjline.commonsimages
 echo "Article : $pjline<br \>" » $Pagesclipco
 echo "Article : $pjline"
 while read htmlline
 do
 echo ""
 echo ""
 echo "---- ligne lue = $htmlline ---"
 echo ""
 mkd -pw '**' $htmlline $htmlline.tmp
 cat $htmlline.tmp | tr ',' '\n' > $htmlline.co.str 
 echo -n "Illustration : " > $htmlline.co.title
 cat $htmlline.co.str | grep wgTitle | cut -d '"' -f4 » $htmlline.co.title
 cat $htmlline.co.title » $Pagesclipco 
 cat $htmlline.co.title
 echo -n ", "source : "https://commons.wikimedia.org/wiki/" > $htmlline.co.source
 echo -n $htmlline | sed "s/.html//g" | sed "s/.str//g" » $htmlline.co.source
 if [ "$Site" = "fr.wikibooks.org" ]; then echo "?uselang=fr" » $htmlline.co.source
 elif [ "$Site" = "en.wikibooks.org" ]; then echo "?uselang=en" » $htmlline.co.source
 else echo
 fi
 cat $htmlline.co.source » $Pagesclipco
 cat $htmlline.co.source
 echo -n ", "licence : "" > $htmlline.co.license
 cat $htmlline.co.str | grep licensetpl_short | sed "s/<td>//g" | sed "s/<span class//g" | sed "s/<\/span>//g" | sed "s/style=\"display:none;\"//g" | tr '=' '\n' | grep licensetpl_short | awk -F">" '{print $NF}' » $htmlline.co.license
 cat $htmlline.co.license » $Pagesclipco
 cat $htmlline.co.license
 echo -n " > tmp
 echo -n ", "auteur(s) : "" > $htmlline.co.auteur
 cat $htmlline.co.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp
 read Tmp < tmp
 #T
 echo "Tmp = $Tmp"
 if [ "$Tmp" = "" ]
 #T then echo "tmp vide"
 then echo "-" > tmp 
 fi
 #T echo $Tmp | cut -d '-' -f2 | sed "s/\.\ /%/g" | cut -d '%' -f1 
 cat tmp » $htmlline.co.auteur
 cat $htmlline.co.auteur » $Pagesclipco
 cat $htmlline.co.auteur
 echo "" » $Pagesclipco
 done < commonshtml.list
 fi
 done < $Projectdir/$1.pj
 echo "</div>" » $Pagesclipco
 echo "" » $Pagesclipco
exit 0
tests_add_sclipco.bash.
VERSION=210709
 clear
 pwd > pwd.txt
 if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
 then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
 rm pwd.txt 
 source $Workdir/vars/installdir.var
 echo " tests_add_sclipco.bash version = $VERSION"
 sleep 2
 echo -e "\033[1;33m Control add_sclipco.sh in the local test directory \033[0m" > text-control.txt 
 echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" » text-control.txt
 echo » text-control.txt
 echo -e "\033[1;33m### add_sclipco.sh ###\033[0m" » text-control.txt
 grep -n -e "#T\|#O\|#P" add_sclipco.sh » text-control.txt
 echo » text-control.txt
 echo -e "\033[1;33m###### en_sclipco.inc.sh ###\033[0m" » text-control.txt
 grep -n -e "#T\|#O\|#P" en_sclipco.inc.sh » text-control.txt 
 echo » text-control.txt
 echo -e "\033[1;33m###### fr_sclipco.inc.sh ###\033[0m" » text-control.txt
 grep -n -e "#T\|#O\|#P" fr_sclipco.inc.sh » text-control.txt 
 echo -e "\033[1;33m ---- \033[0m" » text-control.txt
 more text-control.txt
 echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
 read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
 if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
 #O Test with first param empty
 echo "Command ./add_sclipco.sh without parameter"
 ./add_sclipco.sh
 echo;echo " wait for 2 sec"
 sleep 2; echo "----"
 echo " All tests whith parameter --t" 
 Inkey=1
 for i in 'seq 1 9'
 do 
 cat $Workdir/tests/sitelist.txt; echo
 echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
 read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
 if [ "$Inkey" = "1" ]; then ./add_sclipco.sh LivreTest --t
 elif [ "$Inkey" = "2" ]; then ./add_sclipco.sh Hélices_de_navires_à_déplacement --t
 elif [ "$Inkey" = "3" ]; then ./add_sclipco.sh TestBook --t
 elif [ "$Inkey" = "4" ]; then ./add_sclipco.sh Mkd_\(Extracteur_de_documents\) --t
 elif [ "$Inkey" = "5" ]; then ./add_sclipco.sh Faire_fleurir_le_sel --t
 elif [ "$Inkey" = "6" ]; then ./add_sclipco.sh Faire_sa_fleur_de_sel --t 
 elif [ "$Inkey" = "7" ]; then ./add_sclipco.sh Guide_to_Unix --t
 elif [ "$Inkey" = "8" ]; then ./add_sclipco.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs --t
 elif [ "$Inkey" = "9" ]; then ./add_sclipco.sh LivreTest --t
 else echo "$inkey local url of site not found"; exit 0
 fi
 done