my-scripts/wmf2svg.sh

60 lines
1.8 KiB
Bash
Raw Normal View History

2021-11-01 18:01:52 +00:00
#!/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}