From f9cdcd3638fffeee98d0e4ab6c821661c9cff724 Mon Sep 17 00:00:00 2001 From: ub1x Date: Mon, 1 Nov 2021 18:16:20 +0100 Subject: [PATCH 1/4] pg-add-comment.sh -> make_exif-name.sh umbenannt und im README.md aktualisiert --- jpg-add-comment.sh => make_exif-name.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename jpg-add-comment.sh => make_exif-name.sh (96%) mode change 100644 => 100755 diff --git a/jpg-add-comment.sh b/make_exif-name.sh old mode 100644 new mode 100755 similarity index 96% rename from jpg-add-comment.sh rename to make_exif-name.sh index 5783867..40965cb --- a/jpg-add-comment.sh +++ b/make_exif-name.sh @@ -1,7 +1,7 @@ #!/bin/bash # Add a exif-comment to all JPEG-Files from this directory and all subdirectorys # -# (c) LUG-VS (GPL) +# (c) by Ulf Bartholomäus ub1x@gmx.net VERSION="make_exif-name.sh Version 0.0.2 from 23.10.2005" # # Input: comment text @@ -29,4 +29,3 @@ echo "Write Comment: <"${COMMENTSTEXT}">" # -p Preserve timestamps (atime + mtime) when doing inplace editing. # -c Set jpeg comment tag to . find . -type f -name "${JPEGFILEFILTER}" -exec exiftran -ibp -c "${COMMENTSTEXT}" {} \; - From 8bf2e9b3ecb555cf4e9f157aed7d7370dc98c2da Mon Sep 17 00:00:00 2001 From: ub1x Date: Mon, 1 Nov 2021 19:00:09 +0100 Subject: [PATCH 2/4] Addet utf8.sh write-exif-comment.sh --- README.md | 4 +++- utf8.sh | 32 ++++++++++++++++++++++++++++++++ write-exif-comment.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100755 utf8.sh create mode 100755 write-exif-comment.sh diff --git a/README.md b/README.md index 290394a..2ac042a 100644 --- a/README.md +++ b/README.md @@ -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))| diff --git a/utf8.sh b/utf8.sh new file mode 100755 index 0000000..826d23d --- /dev/null +++ b/utf8.sh @@ -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�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 diff --git a/write-exif-comment.sh b/write-exif-comment.sh new file mode 100755 index 0000000..4095868 --- /dev/null +++ b/write-exif-comment.sh @@ -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} From 6742b90d01557923c54e65c3a04805d3a5fa028a Mon Sep 17 00:00:00 2001 From: ub1x Date: Mon, 1 Nov 2021 19:01:52 +0100 Subject: [PATCH 3/4] SchredderHDD.sh and wmf2svg.sh added --- README.md | 6 ++- SchredderHDD.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ wmf2svg.sh | 59 +++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100755 SchredderHDD.sh create mode 100755 wmf2svg.sh diff --git a/README.md b/README.md index 2ac042a..0c01d28 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # my-scripts -My personally used scripts +My personally or users our LUG-VS used scripts + +See also at [LUG-VS-Wiki Nützliche Scripte](https://lug-vs.org//lugvswiki/index.php?title=Nuetzliche_Scripte) (German) + ## Content @@ -11,4 +14,5 @@ My personally used scripts |[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))| +|[SchredderHDD.sh](SchredderHDD.sh)|Delete a mechanical Hard Disk (HDD) in a relayeable way to ensure before forward it to the recycling, that no old data are there| diff --git a/SchredderHDD.sh b/SchredderHDD.sh new file mode 100755 index 0000000..c1e0886 --- /dev/null +++ b/SchredderHDD.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# Löscht ein komplettes Device +# Version 0.2.0 +# Vom 2012-10-15 Aktualisert am 2021-01-24 +# (c) LUG-VS (GPL) + +##Status anzeigen: +#sudo kill -SIGUSR1 $(pidof dd) + +# teste ob vorhanden +if [ "`whoami`" != "root" ] ; then + echo 'Nicht ausreichend Rechte - bitte als "root" anmelden!' + exit 10 +fi + +# Überprüft ob Parameter vorhanden +if [ $# -lt 1 ] ; then + echo 'Device angeben z.B. "'$0' /dev/sdf"' + exit 20 +fi + +# teste ob vorhanden +if [ ! -b $1 ] ; then + echo 'Device existiert nicht' + echo 'Device angeben z.B. "'$0' /dev/sdf"' + exit 30 +fi + +# Device zuweisen +OF=$1 +SIZE=$(fdisk -l ${OF} 2> /dev/null | grep ${OF} | sed -r "s/.*\, (.*) byte.*/\1/I") +NAME=$(fdisk -l ${OF} 2> /dev/null | head -n2 | tail -n1 | sed 's/.*: *//' | sed 's/ *//') +RNDOM=$(( 20 * 1024 * 1024 )) # Durchsatz bei Zufallszahlen in B/s +NULLS=$(( 40 * 1024 * 1024 )) # Durchsatz bei Zufallszahlen in B/s +RDURATION=$(( ${SIZE} / ${RNDOM} )) +NDURATION=$(( ${SIZE} / ${NULLS} )) +DURATION=$(( ${RDURATION} + ${NDURATION} )) +#echo "Random=<${RNDOM}> NULLS=<${NULLS}> RDURATION=<${RDURATION}> NDURATION=<${NDURATION}> DURATION=<${DURATION}>" + +# Letze Nachfrage +echo -e "Info ($(date '+%A, %T Uhr')): $OF hat eine Größe von $((${SIZE}/1073741824))GB! Damit dauert mit anschließenden schreiben von Nullen bei typischen Durchsatz etwa $((${DURATION}/3600)) Stunden!" +echo -en "*** Achtung! Device (Festplatte) ${OF} (${NAME}) wirklich löschen? (j/n) " +read -n 1 key +echo -e "\n" +if [ "${key}" != "j" ] ; then echo 'Antwort nicht "j" => abgebrochen durch Benutzer'; exit 1; fi; + +# Laufwerk aushängen +echo -en "Info ($(date '+%A, %T Uhr')): Laufwerk aushängen: " +umount -f ${OF}* + +# Zufallszahlen Schreiben bis +TIME=$(date "+%A, %T Uhr") +RTIME=$(date "+%A um %H:%M Uhr" --date="+${RDURATION} seconds") +FTIME=$(date "+%A um %H:%M Uhr" --date="+${DURATION} seconds") +echo -e "Info (${TIME}): $OF hat eine Größe von $((${SIZE}/1073741824))GB, was bei typischen Durchsatz von $((${RNDOM}/1048576))MB/s etwa bis ${RTIME} für das schreiben der Zufallszahlen dauert!" +echo -e "Info (${TIME}): Damit dauert mit anschließenden schreiben von Nullen bei typischen Durchsatz von $((${NULLS}/1048576))MB/s etwa bis ${FTIME}!" +##dd random +dd if=/dev/urandom of=${OF} bs=4M iflag=fullblock oflag=direct status=progress +sync +#echo -e "\n" +TIME=$(date "+%A, %T Uhr") +NTIME=$(date "+%A um %H:%M Uhr" --date="+${NDURATION} seconds") +echo -e "Info (${TIME}): $OF hat eine Größe von ${SIZE} bytes, was bei typischen Durchsatz von $((${NULLS}/1048576))MB/s etwa bis ${NTIME} für das schreiben der Nullen dauert!" +##dd null +#dd if=/dev/zero of=${OF} bs=64k +dd if=/dev/zero of=${OF} bs=4M iflag=fullblock oflag=direct status=progress +sync +TIME=$(date "+%A, %T Uhr") +echo -e "Info (${TIME}): $OF (${NAME}) sicher gelöscht!" + +## Bisher +# echo 'Laufwerk aushängen' +# umount -f ${OF}* +# +# Zufallszahlen beschreiben und anschließend löschen +# date +"%F %T" +# echo 'Schreibe Zufallszahlen auf' ${OF} +# dd if=/dev/urandom of=${OF} +# dd if=/dev/urandom of=${OF} bs=4M iflag=fullblock oflag=direct status=progress +# sync +# echo -en "\n" +# date +"%F %T" +# echo 'Schreibe Nullen auf' ${OF} +# dd if=/dev/zero of=${OF} bs=64k +# dd if=/dev/zero of=${OF} bs=4M iflag=fullblock oflag=direct status=progress +# sync +# date +"%F %T" +# echo 'Device (Festplatte)' ${OF} 'sicher gelöscht' +# OF= +# +# 4 mal lüten +#for (( INDEX=4 ; ${INDEX} ; INDEX=$(( ${INDEX} - 1 )) )) ; do +# beep # => beep wird nicht gefunden ist auch kein alias ???!!! +# wait +#done +#INDEX= + +## diff --git a/wmf2svg.sh b/wmf2svg.sh new file mode 100755 index 0000000..2817911 --- /dev/null +++ b/wmf2svg.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Simple script to "convert" a grafik file format to an other +# +# (c) LUG-VS (GPL) +VERSION="wmf2svg.sh Version 0.0.2 from 2006-12-27" +# +# Input: path +# Output: changed files +# +# Changes: +# 0.0.2: rebuild with temporary convertion file +# 0.0.1: generation +# + +FORMATin=.wmf +FORMATout=.svg +TEMPfile=`dirname $0`/$$.sh +EXECpath=. + +# trap is executed if script breaks (remove temporary file if exists) +trap "echo '*** TRAP ***' ; test -e ${TEMPfile} && rm ${TEMPfile} ; exit" ERR + +# check if command exists else break +which convert > /dev/null || echo "convert not found!" || exit; + +# check if filename exists +if [ -e ${TEMPfile} ] ; then + echo '${TEMPfile} exists => call this comand a 2-nd time' + exit +fi + +# if path exists and is a path => use it +if [ -d $1 ] ; then + EXECpath=$1 +fi + +# generate temporary script for manipulation and made it executable +# change in this sektion what is to do +# the "echo" comand writes the comand lines in the ${TEMPfile} +echo '#!/bin/bash' > `echo ${TEMPfile}` +echo -e 'myFILEin=$1\nmyFILEout=`dirname $1`/`basename $1 '${FORMATin}'`"'${FORMATout}'"' >> `echo ${TEMPfile}` +echo -e 'echo convert ${myFILEin} ${myFILEout}' >> `echo ${TEMPfile}` +echo -e 'convert ${myFILEin} ${myFILEout}' >> `echo ${TEMPfile}` +echo -e '# write what you want to do without coment char "#" in this line' >> `echo ${TEMPfile}` +echo -e '# rm ${myFILEin} ;# remove "#" befor rm if you want to delete the source' >> `echo ${TEMPfile}` +chmod +x ${TEMPfile} + +# echo what is to do +echo 'Start recursive convertion from *'${FORMATin}' in *'${FORMATout} + +# find all files (not case sensitive) that matching filter and execut script +find ${EXECpath} -type f -iname "*${FORMATin}" -print0 | xargs -0 -n1 ${TEMPfile} + +# debug => remove this line if not need +cat ${TEMPfile} + +# remove the temporary script +rm ${TEMPfile} + From c9cc97bd61afa2cac16e4c4ccbf31178d976cca9 Mon Sep 17 00:00:00 2001 From: ub1x Date: Mon, 1 Nov 2021 19:06:58 +0100 Subject: [PATCH 4/4] Added wmf2svg.sh description in the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c01d28..baa4875 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,5 @@ See also at [LUG-VS-Wiki Nützliche Scripte](https://lug-vs.org//lugvswiki/index |[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))| |[SchredderHDD.sh](SchredderHDD.sh)|Delete a mechanical Hard Disk (HDD) in a relayeable way to ensure before forward it to the recycling, that no old data are there| +|[wmf2svg.sh](wmf2svg.sh)|Example script converts WMF files in SVG to share it easily in the internet|