Addet utf8.sh write-exif-comment.sh

This commit is contained in:
Ulf 2021-11-01 19:00:09 +01:00
parent f9cdcd3638
commit 8bf2e9b3ec
3 changed files with 62 additions and 1 deletions

View file

@ -8,5 +8,7 @@ My personally used scripts
|---|---|
|[duc-index.sh](duc-index.sh)|Script to be added e.g. as cronjob, which generate an index w/o nfs and dfs filesystem mounted files|
|[diskfree.sh](diskfree.sh)|Script shows the free memory of all mounted filesystems beside *tmpfs|
|[jpg-add-comment.sh](jpg-add-comment.sh)|Add a comment in all *.jpg files in the actuall and all subfolders|
|[make_exif-name.sh](make_exif-name.sh)|Add a comment in all *.jpg files in the actuall and all subfolders|
|[write-exif-comment.sh](write-exif-comment.sh)|Write JPEG EXIF comment in all *.jpg pocures|
|[utf8.sh](utf8.sh)|Convert text from e.g. Windows latin1 to utf8 text (e.g. in READMEs or other text (not for office documents))|

32
utf8.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
# Script wich converts a file in 'text/plain' from an not utf8 char set to utf8 char set
#
# (c) by Ulf Bartholom<6F>s ulfbart@gmx.de
VERSION="$0 Version 0.1.0 from 20.09.2006"
#
if [ "$1" == "" ]; then
echo "Please enter Filename as first option which should be converted"
echo
echo -e "INFO:\n\tTo convert all old latin1 file-names in new utf8 file-names use:"
echo -e "\t\t'convmv --notest -r -f latin1 -t utf-8 *'\n"
exit -1
fi
myNEWNAME=$1
myNEWNAMEsik=$(echo ${myNEWNAME}~)
myFILETYPE=$(file -bi ${myNEWNAME} | cut -d';' -f1)
myCHARSET=$(file -bi ${myNEWNAME} | cut -d'=' -f2)
# if Filetype is convertable
if [ "${myFILETYPE}" == "text/plain" ] && [ "${myCHARSET}" != "utf8" ]; then
# If sik file exists break with error message
test -e ${myNEWNAMEsik} && echo "File <${myNEWNAMEsik}> exists" && exit -2
mv ${myNEWNAME} ${myNEWNAMEsik}
# Convert the old CharSet in utf8
echo "Convert ${myNEWNAME} from ${myCHARSET} to utf8"
iconv -f ${myCHARSET} -t utf8 -o ${myNEWNAME} ${myNEWNAMEsik}
else
# Print error Message
echo "Filetype not 'text/plain' (${myFILETYPE}) or char set is 'utf8' (${myCHARSET})"
fi

27
write-exif-comment.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# Write a exif-comment to all JPEG-Files from this directory and all subdirectorys
#
# (c) LUG-VS (GPL)
VERSION="write-exif-comment.sh Version 0.0.1 from 16.06.2019"
#
# Input: InImage [OutImage]
# Output: changed files
#
# Changes:
# 0.0.1: generation
#
test -e $1 || exit -1
FilenameFull="$1"
if [ $# -gt 1 ] ; then
FilenameSik="$2"
else
Extension="${FilenameFull##*.}"
FilenameBase="${FilenameFull%.*}"
FilenameSik="${FilenameBase}New.${Extension}"
fi
CommentsText="$(convert ${FilenameFull} -format "%c\n" info:)"
Width=$(identify -format %w ${FilenameFull})
High=$(( $(identify -format %h ${FilenameFull}) / 10))
echo "EXIF-Kommentar= <${CommentsText}> of <${FilenameFull}> (${Width}x${High} ${FilenameSik})"
convert -background '#0008' -fill white -gravity center -size ${Width}x${High} caption:"${CommentsText}" \
${FilenameFull} +swap -gravity south -composite ${FilenameSik}