1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SVGファイルを一気にepsに変換する方法

Posted at

背景

texにベクター画像を使用したい場合、グラフであればmatplotlibで描画してsvgで保存、epsに変換というのが一つの方法です。ポンチ絵の作図ならばpptでsvg保存→epsに変換が主な流れでしょうか。1枚や2枚程度のsvgファイルであればオンライン上のコンバータを使用してepsに変換すれば良いのですが、大量にある場合非常に面倒です。まして修正が入るたびに手作業でやるのは非効率です。そのためにwin上でフォルダ内にあるsvgファイルを変換するバッチファイルを作成しました。

参考

環境

  • windows10
  • Inkscape1.1 32bit版

Inkspaceがインストールされていない前提です。既にインストールされている場合は下記手順4から行ってください。

手順

  1. Iinkscapeダウンロード (https://inkscape.org/ja/release/inkscape-1.1/)
  2. インストール
  3. 環境変数設定
  4. batファイル作成
  5. svg→epsへ変換

1.Iinkscapeダウンロード

公式HP https://inkscape.org/ja/release/inkscape-1.1/ の上記画面の左下から「Windows」版(本稿では32bit)をダウンロードします。

2. インストール

インストーラーを実行するだけでOKです。
image2.png

3. 環境変数設定

Windows左下の検索窓にcmdと打ってコマンドプロンプトを検索し、管理者として実行します。
image4.png

コマンドラインに
Start C:\Windows\system32\rundll32.exe sysdm.cpl, EditEnvironmentVariables
と打ち込んで環境変数の設定画面を開きます。

次にシステム環境変数一覧のpathの項目を選択し編集をクリックします。最後に新規ボタンをクリックして、Inkspaceをインストールしたフォルダ内にありbinの場所を指定します。(私の環境では「C:\Program Files (x86)\Inkscape\bin」でした)。以下のように設定できれば成功です。
image8.png

4. batファイル作成

メモ帳を開き、以下をコピペしてください。https://kimaguremono.hateblo.jp/entry/inkscape_cmdの記事を参考にしました。

@echo off
dir *.svg /b > filelist.txt
for /f "tokens=1 delims=." %%a in ( filelist.txt ) do (
inkscape -p %%a.svg -o %%a.eps
)
del filelist.txt

そして「任意の名前.bat」という名前で保存してください。

5. svg→epsへ変換

変換したいsvgファイルのあるフォルダに4.で作成したbatファイルを置きます。そのbatファイルをダブルクリックすることでsvgからepsへの変換が始まります。

以上です。一度Inkscapeの設定(1.-3.)ができれば別のsvgファイルを変換する場合、そのファイルがあるフォルダにbatファイルをコピーして、同じようにすれば良いです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?