Save this file as ai2svg
, make it executable via chmod +x ai2svg
then run it optionally passing the folder to look for.
It will convert in that folder, or the current one, all .ai files into .svg
#!/usr/bin/bash
createsvg() {
local margin="$1"
local d
local svg
for d in *.ai; do
svg=$(echo "$d" | sed 's/.ai/.svg/')
echo "creating $svg ..."
# old version: inkscape "$d" -l -o "$svg"
if [ "$margin" != "" ]; then
inkscape "$d" --export-area-drawing --export-margin $margin "--export-plain-svg=$svg"
else
inkscape "$d" --export-area-drawing "--export-plain-svg=$svg"
fi
done
}
if [ "$1" != "" ];then
cd $1
fi
createsvg "$2"
I had to add
d=$(echo "$(cd "$(dirname "$d")"; pwd)/$(basename "$d")")
as the first line of thefor
loop to make the path to$d
absolute, otherwiseinkscape
just erred that it couldn't find the file.