我有一个文件夹,其中包含数以千计的.ai文件,我想使用Mac终端批量转换为.svg文件。
到目前为止,我是通过Adobe Illustrator完成的,但是批量转换.ai到.svg需要几天的时间。
有没有办法通过航站楼呢?
附注:请记住,我不是一个软件开发人员,而是一个普通用户,所以请尽可能简单地解释细节,否则我会迷失方向,需要进一步的说明:)
谢谢
发布于 2016-04-08 03:17:47
Inkscape有一些很棒的命令行工具可以做到这一点。Check out their wiki page on this。
他们的python脚本ai2svg.py看起来应该可以做到这一点。尝试执行以下命令:
find . -name "filename*" -exec python ai2svg.py '{}' \;
将filename*替换为要处理的匹配文件名。要了解有关在多个文件上执行命令的更多信息,请参阅this post。
希望这能有所帮助!
发布于 2017-10-05 00:52:02
Mikel建议的ai2svg.py脚本为我挂起,但似乎Inkscape可以直接从终端调用,并且可以很好地完成工作:
将以下脚本另存为文件ai2svg
,使其可通过chmod +x ai2svg
执行,然后运行它,可以选择传递文件夹以查找Illustrator文件。
它会将该文件夹或当前文件夹中所有.ai文件转换为.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
来源:https://gist.github.com/WebReflection/b5ab5f1eca311b76835c
发布于 2019-12-09 05:33:28
这是受到the21st's version的启发。它转换在命令行上指定的文件,因此它也可以处理单个文件。由于原始问题提到了批量工作,空间可能是一个问题,因此此脚本压缩生成的svg。在我的例子中,与原始的.ai文件相比,这可以节省90-95%的空间。
#!/bin/sh
set -e
for file in "$@"
do
case "$file" in
*.ai|*.AI)
outfile=$(echo "$file" | sed 's/.ai/.svg/i')
zoutfile=$(echo "$file" | sed 's/.ai/.svgz/i')
if [ -e "$outfile" -o -e "$zoutfile" ]; then
echo "'$outfile' already exists, skipping"
else
inkscape --file="$file" --export-plain-svg="$outfile"
gzip -9 "$outfile"
mv "$outfile".gz "$zoutfile"
fi
;;
*)
echo "'$file' does not have an .ai extension, skipping"
;;
esac
done
https://stackoverflow.com/questions/36485012
复制相似问题