Skip to content

Instantly share code, notes, and snippets.

@jiri001meitner
Last active September 5, 2024 00:57
Show Gist options
  • Select an option

  • Save jiri001meitner/587ae14f577d1f3e97b75254dded999d to your computer and use it in GitHub Desktop.

Select an option

Save jiri001meitner/587ae14f577d1f3e97b75254dded999d to your computer and use it in GitHub Desktop.
batch_generate_qr_codes_and_labels.sh
#!/bin/bash
script_path="$(dirname "$(realpath "${0}")")"
cd "${script_path}"||exit 1
stitky_vystup_slozka="${script_path}/output/stitky"
qr_vystup_slozka="${script_path}/output/qr"
template="${script_path}/stitek.svg"
# mazání starých štítků a qr kódů
find "${script_path}/output" -type f -delete
mkdir -p "${stitky_vystup_slozka}" "${qr_vystup_slozka}"
# Načtěte čísla, pro která chcete generovat QR kódy
mapfile -t numbers < <(echo {000000..002000} | tr ' ' '\n' | sed -r 's/(..)(..)(..)/\1-\2-\3/')
# Pro každý generovaný QR kód
for number in "${numbers[@]}"; do
# Generujte QR kód jako SVG
qrencode -m 1 --inline --8bit --rle -o "${qr_vystup_slozka}/${number}.svg" -t SVG <<EOF
BEGIN:VCARD
VERSION:4.0
N:;ALTR-${number}
ORG:IT is Love
TITLE:SERVIS
TEL:774999082
URL:itislove.cz
END:VCARD
EOF
head -n 419 "${template}"|sed "s/NUMBER/${number}/g" > "${stitky_vystup_slozka}/stitek-${number}.svg"
grep 'rect' "${qr_vystup_slozka}/${number}.svg" >> "${stitky_vystup_slozka}/stitek-${number}.svg"
cat <<'EOF'>>"${stitky_vystup_slozka}/stitek-${number}.svg"
</g>
</g>
</svg>
</g>
</g>
</svg>
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment