How to Batch Convert EPS and AI Files to PDF in Linux

In a previous post we discussed the basics of viewing and converting EPS and AI files in Linux. Just in case you missed it, you can find that post below:

https://www.victorianodejesus.com/viewing-and-converting-eps-and-ai-files-in-linux/

In this post, I’ll show you how to batch convert EPS and AI files using a simple BASH script. Note that this method works for Linux Mint 18.3 (Ubuntu 16.04). It should work for other Ubuntu-based Linux distributions.

Install required programs

You will need epstopdf (texlive-font-utils) and ghostscript. To install, open a terminal and type:

sudo apt-get install texlive-font-utils ghostscript

Create a Script File

Open up any text editor and paste the following commands:

#!/bin/bash

#Batch convert .EPS and .AI files into .PDF format

#EPS to PDF batch convert
#make sure you downloaded eps-to-pdf
#To install type 'sudo apt-get install texlive-font-utils' in terminal
for file in *.eps; do epstopdf "$file"; done

#AI to PDF batch convert
#Uses Ghostscript; make sure to have Ghostscript installed
#To install type 'sudo apt-get install ghostscript' in terminal
for file in *.ai; do gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${file/%ai/pdf}" "$file"; done

Save this file as ‘convert-eps-ai-to-pdf.sh

Make script executable

Make the script executable by right clicking and selecting “Allow this file to run as program”. (This is for Thunar File Manager in XFCE).

Or run the following command in a terminal:

chmod +x convert-eps-ai-to-pdf.sh

Run the script

You can move this script file into any folder.

Add any EPS and AI files that need to be converted into the folder.

Open a terminal in that folder and type the following command to run the conversion:

./convert-eps-ai-to-pdf.sh

And you’re done!

For a complete video walkthrough, check out the video below:

Leave a Reply