Command Line Barcode Generation

Barcode can be used from 3rd party application or scripts to generate barcodes in command line mode. The only thing you need is to configure the barcode appearance first and then you can use it as a template for generating barcodes. In this tutorial we assume that you have a barcode named “EAN-13” configured in the barcodes list. If not, you need to do it first or use a different barcode name in the code examples below.

Simple Barcode Generation

Barcode expects to see some command line parameters to switch to the command line mode. These parameters are --symbology, --data and --output. All three need to be specified, as otherwise Barcode will start in the standard, visual mode.

Here is the simplest command line example for Mac:

/Applications/ --symbology=EAN-13 --data=1234567890128 --output=result.png

A similar line for Windows is:

"C:\Program Files\Appsforlife\Barcode\Barcode.exe" --symbology=EAN-13 --data=1234567890128 --output=result.png

This makes a PNG file with the barcode design you configured and the data you provided. You can use other file types, like PDF, EPS, TIFF or TIF. The latter is the monochrome one.

Add-on Processing

For EAN-13, ISBN-13 and UPC-A barcodes you can specify add-on using a semicolon in the --data parameter this way:


This gives you a barcode with main text set to “12345678901238” and the add-on set to “12345”.

For ISBN-13 barcodes you specify the price in decimal format like this:


Which makes an add-on “51020” if the barcode is configured to use the US pricing mode.

Batch Barcode Generation

For batch generation you can either run the code above multiple times using your favorite scripting tool or language, or use the built–in batch generation feature of the Barcode. To do so, you need to put all the barcodes you want to generate in a plain text file, so each line represents a single barcode’s data. Like this:


Then you can run Barcode this way. On Mac:

/Applications/ --symbology=EAN-13 --source=data.txt --output=result.png

On Windows:

"C:\Program Files\Appsforlife\Barcode\Barcode.exe" --symbology=EAN-13 --source=data.txt --output=result.png

The difference is that the --data parameter is replaced with the --source parameter which points to the text file with barcodes.

After you run the line above, you’ll get a set of files named this way:


As you may see, Barcode used the --output parameter you provided to get a prefix and extension for the generated files. The rest of the name is made of the barcode data provided in the text file.

Batch Barcode Generation With Counter

Instead of using barcode data for naming the file, you can configure Barcode to name the output files using a counter. You can do it this way:

Then you can run Barcode this way. On Mac:

/Applications/ --symbology=EAN-13 --source=data.txt --mode=counter --counter-from=100 --output=result.png

On Windows:

"C:\Program Files\Appsforlife\Barcode\Barcode.exe" --symbology=EAN-13 --source=data.txt --mode=counter --counter-from=100 --output=result.png

You can see that two parameters have been added: --mode=counter, which enables the using of counter for naming, and the optional --counter-from=100 which sets the first number to use for the counter. After running the line above for the same text file, you’ll get these files:


This is pretty much the same, as you configure it in the visual mode. Although Barcode remembers what type of generation you used the last time, it doesn’t use that information for command line processing to make it more predictable.

Batch Barcode Generation With Scripting

Another way of doing the same if you want more flexibility is to use a scripting language to process the text file and use Barcode maker to generate one barcode at a time. Here is a Mac example using the bash script:


while read code; do
	echo "Processing ${code}"
	/Applications/ --symbology=EAN-13 --data=$code --output=$code.png
done < data.txt

Same code for Windows is below:

for /f %%i in (data.txt) do (
	"C:\Program Files\Appsforlife\Barcode\Barcode.exe" --symbology=EAN-13 --data=%%i --output=%%i.png

In both cases we use the scripting language to read the text file line by line and call Barcode to generate images for us. This way you get more flexibility with the file naming and symbology selection.

Single File Batch Generation

You can also output barcodes to a single file this way on Mac:

/Applications/ --symbology=EAN-13 --source=data.txt --mode=single --output=result.pdf

On Windows:

"C:\Program Files\Appsforlife\Barcode\Barcode.exe" --symbology=EAN-13 --source=data.txt --mode=single --output=result.pdf

The command lines parameters are pretty much the same as shown above for multiple file output, but this time we used --mode=single parameter, which tells Barcode to output everything to the same file. The output file should have a PDF extension, as only this one is supported by the software.

Running the line above should give you a PDF file with all the barcodes you listed in the text file. Barcode will use the grid settings you configured when you last time used the batch processing in visual mode for this generator. It is the same as with the visual appearance: you first configure it with the user interface, then you can use it from the command line.

Modes Overview

So once again, a single barcode is rendered using the --data parameter, multiple barcodes are rendered using the --source parameter and a text file with barcode data. For multiple barcodes there is a special --mode parameter which could have one of the following values:

If this is not enough, consider using a custom script which calls Barcode with the --data parameter and renders barcodes one by one.

More Barcode Tutorials



UPC Barcodes

Other Barcodes