DEV Community

Ebenezer Lamptey
Ebenezer Lamptey

Posted on

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. 🚀

Top comments (0)