DEV Community

Ebenezer Lamptey
Ebenezer Lamptey

Posted on

2

Saving Time: Batch QR Code Generation with Bash

Ever found yourself manually creating QR codes one by one? As a choir marketing committee member, I was frustrated with online tools that either:

  • Limit free users to one QR code
  • Charge for bulk generation
  • Waste precious time

The Frustration

Our choir needed QR codes for multiple YouTube links to print on marketing t-shirts. Existing solutions? Painfully slow and expensive.

The Bash Solution

I wrote a simple script to automate QR code generation:

bash

# Check if input file is provided
if [ -z "$1" ]; then
    echo "Usage: $0 <input_file>"
    exit 1
fi

input_file="$1"

# Create a directory to store QR codes
mkdir -p qr_codes

# Generate QR codes for each URL in the input file
while IFS= read -r url; do
    filename="qr_codes/$(basename "$url").png"
    qrencode -o "$filename" "$url"
    echo "Generated QR code for $url"
done < "$input_file"

echo "QR codes saved in 'qr_codes' directory."

Enter fullscreen mode Exit fullscreen mode

Key Benefits

  • Free
  • Fast
  • Customizable
  • No subscription needed

How It Works

  • Create a text file with URLs
  • Run the script
./qr_code.sh <text file>

Enter fullscreen mode Exit fullscreen mode

Get QR codes in seconds

Pro Tips

  • Use with qrencode
  • Works for any links, not just YouTube
  • Easily scriptable and modifiable

You can see the code in my github
https://github.com/nlankwei5/Create-Qr-code/blob/main/qr_code.sh

Feel free to try it and give comments for more improvements
No more manual, repetitive work. 🚀

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay