Results 1 to 7 of 7

Thread: Help using qrencode

  1. #1
    Join Date
    Aug 2012
    Beans
    5

    Question Help using qrencode

    Helo everyone

    im pretty new to linux and ubuntu but I managed to get everything running on a virtualbox

    I was able to install qrencode easily and i can generate simple codes using a text file as input.

    the code is qrencode -o qrtest.png -s 6 < qr.txt

    is it possible to somehow tell the terminal to do all text files in a certain folder and name the QR codes after the text file?

    thanks in advance and sorry if this is the wrong place for this

    et
    Last edited by skycaptainbs; August 22nd, 2012 at 10:03 AM. Reason: missed something

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Help using qrencode

    Code:
    for f in *.txt; do qrencode -o "${f%.txt}.png" -s 6 < "$f"; done
    Last edited by Vaphell; August 22nd, 2012 at 10:23 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Aug 2012
    Beans
    5

    Re: Help using qrencode

    thank you alot.

    i think I understand it.

    I'll report back!

  4. #4
    Join Date
    Aug 2012
    Beans
    5

    Re: Help using qrencode

    Yes perfect!

    if you have the time.. would you explain what exactly it does?

    no worries if not.

  5. #5
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Help using qrencode

    Code:
    for f in *.txt; ...
    iterate all files matching <anything>.txt, store the current name in f variable...
    Code:
    ... do qrencode -o "${f%.txt}.png" -s 6 < "$f"; done
    loop body: execute qrencode and in proper places use $f (get value of f) placeholder which will substitute the name of the file.
    ${f%.txt}.png = get f, strip .txt from the right and add .png
    ${f%pattern} is one of the parameter expansion features, there are more
    http://www.gnu.org/software/bash/man...eter-Expansion

    Code:
    for f in *.txt; do echo qrencode -o "${f%.txt}.png" -s 6 < "$f"; done
    you can use echo so the whole command is printed out as seen by the shell, not executed. You will see the series of qrencode with individual file names placed in proper spots, 1 for each file.
    Last edited by Vaphell; August 22nd, 2012 at 12:12 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  6. #6
    Join Date
    Aug 2012
    Beans
    5

    Re: Help using qrencode

    wow even though its 2012 im starting to like command lines^^

  7. #7
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Help using qrencode

    because command line roxx, it's intimidating at first, but once you taste a bit of its goodness you feel empowered It's perfect for mundane stuff lending itself to programmatic approach, like perform some action on 1000 files... and the best thing is it's not rocket science
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •