Bulk Command Line QRcode Encoder

I needed a way to bulk convert QRcodes so I created this nifty Perl One-Liner seen below. I am also using a program called qrencode.

NOTE: If you are on a Debian based distro you can use sudo apt-get install -y qrencode to install it šŸ™‚

Parameters

With the program qrencode I am using the following parameters:

  • --size=NUMBER (size of the QRcode)
  • --margin=NUMBER (Margin size of the QRcode)
  • --output=FILENAME (Name of the outputted file)

QRcode Text File

You will need to provide a text file for one liner:

  • Each line in the text file will represent a qrcode.
  • To name the file properly you can do it like this: filename****contents of qrcode
    • **** = delimiter
  • EXAMPLE:
    • file01****contents of qrcode
    • file02****MORE qrcode stuff

Perl One-Liner

perl -M'Term::ANSIColor 2.00 qw(:pushpop)' -sne 'BEGIN {print qq~[J\033[H\033[J~}; next if m~^$|^\#~; chomp; @_ = split m~\*{4}~, $_; $_[0] =~ s`[[:punct:]]+(?{ $m="" })|\s+(?{ $m="-" })`$m`ge; $cmd = qq`${qr}\L$_[0]\E.png \x{27}$_[1]\x{27}`; print PUSHCOLOR BRIGHT_GREEN qq`> $cmd\n`; print RESET; system $cmd; sleep 1;' -- -qr="qrencode --margin=0 --size=20 --output="

.bashrc

To make this even more convenient add it to .bashrc!

function qrloop()
{

	perl -M'Term::ANSIColor 2.00 qw(:pushpop)' -sne 'BEGIN {print qq~[J\033[H\033[J~}; next if m~^$|^\#~; chomp; @_ = split m~\*{4}~, $_; $_[0] =~ s`[[:punct:]]+(?{ $m="" })|\s+(?{ $m="-" })`$m`ge; $cmd = qq`${qr}\L$_[0]\E.png \x{27}$_[1]\x{27}`; print PUSHCOLOR BRIGHT_GREEN qq`> $cmd\n`; print RESET; system $cmd; sleep 1;' -- -qr="qrencode --margin=0 --size=20 --output=" $1

}

Syntax

With the .bashrc above you can invoke with qrloop text-with-qr-codes.txt

0Shares
0

Latest Blogs

Leave a Reply