Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch convert .ai to .svg using Mac Terminal

I have a folder that contains thousands of .ai files and I want to batch convert them to .svg files using Mac terminal.

Until now I did it through Adobe Illustrator but it takes days to batch convert .ai to .svg.

Is there any way to do it through the Terminal?

P.S. Keep in mind I am not a software developer but a regular user, so please explain as simple as possible with details, otherwise I will get lost and I will need further instructions :)

Thanks

like image 472
JIM Avatar asked Dec 14 '22 07:12

JIM


2 Answers

Inkscape has some great command line tools for this. Check out their wiki page on this.

Their python script ai2svg.py looks like it should do the trick. Try the following command:

find . -name "filename*" -exec python ai2svg.py '{}' \;

Replace filename* with the matching filename(s) that you want to work on. To learn more about executing commands on multiple files see this post.

Hope this helps!

like image 129
Mikel Duffy Avatar answered Jan 17 '23 12:01

Mikel Duffy


The ai2svg.py script suggested by Mikel hangs for me, but it seems Inkscape can be invoked from Terminal directly and does the job well:

Save the following script as a file ai2svg, make it executable via chmod +x ai2svg then run it, optionally passing the folder to look for Illustrator files.

It will convert in that folder, or the current one, all .ai files into .svg

#!/usr/bin/bash

createsvg() {
  local d
  local svg
  for d in *.ai; do
    svg=$(echo "$d" | sed 's/.ai/.svg/')
    echo "creating $svg ..."
    inkscape -f "$d" -l "$svg"
  done
}

if [ "$1" != "" ];then
  cd $1
fi

createsvg

source: https://gist.github.com/WebReflection/b5ab5f1eca311b76835c

like image 36
the21st Avatar answered Jan 17 '23 12:01

the21st